Skip to content

Commit

Permalink
try time-based approach
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpitt committed Oct 17, 2023
1 parent 240d2b7 commit 27ce96f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/trigger-anaconda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,36 @@ 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 || {
sleep 60
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
Expand Down

0 comments on commit 27ce96f

Please sign in to comment.