From 27ce96fbb1c1fe487c390b543a5bd7e491574562 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 17 Oct 2023 11:41:19 +0200 Subject: [PATCH] try time-based approach --- .github/workflows/trigger-anaconda.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/trigger-anaconda.yml b/.github/workflows/trigger-anaconda.yml index 7054bf381b11..9369d76b139d 100644 --- a/.github/workflows/trigger-anaconda.yml +++ b/.github/workflows/trigger-anaconda.yml @@ -23,6 +23,12 @@ jobs: timeout-minutes: 120 steps: + - name: Debug + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: | + echo "github: $GITHUB_CONTEXT" + - name: Install dependencies run: | dnf install -y git-core dnf-plugins-core || { @@ -30,16 +36,23 @@ jobs: dnf install -y git-core dnf-plugins-core } + # Naïvely this should wait for github.event.pull_request.head.sha, but + # that breaks on non-current branches, which packit merges to main with + # an unpredictable SHA; so instead, wait until COPR has a build which is + # newer than the PR push time. This assumes that this workflow always runs earlier + # than the COPR srpm build finishes. - name: Wait for packit COPR build run: | set -ex + PUSH_TIME=$(date --utc +%Y%m%d%H%M%S -d '${{ github.event.pull_request.head.pushed_at }}') COPR_NAME="${{ github.event.pull_request.base.user.login }}-${{ github.event.pull_request.base.repo.name }}-${{ github.event.number }}" SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c 1-8) for _ in $(seq 60); do sleep 60; if dnf copr enable -y packit/$COPR_NAME && out=$(dnf info --refresh --repo='copr:*cockpit*' cockpit-bridge) && - echo "$out" | grep -q "Release.*\.g$SHA" ; then + stamp=$(echo "$out" | awk '/^Release/ { split($3, v, "."); print substr(v[2], 0, 14)}') && + [ "$stamp" -gt "$PUSH_TIME" ]; then exit 0 fi done