Repository navigation
78 lines (76 loc) · 3.5 KB
/
Copy pathrelease-verify.yaml
File metadata and controls
78 lines (76 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Verify Releases
on:
schedule:
- cron: '0 9 * * *'
# Triggered after Release Components completes to verify the release (including Packagist).
# Release Components is workflow_dispatch-only (maintainers) and this workflow only checks out the default branch.
# zizmor: ignore[dangerous-triggers]
workflow_run:
workflows: ["Release Components"]
types: [completed]
workflow_dispatch:
inputs:
tag:
description: 'Release tag to verify (defaults to unverified releases from the last 14 days)'
required: false
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-latest
name: Verify Releases
permissions:
contents: write
issues: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: '8.2'
- name: Install dependencies
run: composer --no-interaction --no-ansi --no-progress update -d dev
- name: Verify releases
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ inputs.tag }}
run: |
CUTOFF=$(date -u -d "-14 days" +"%Y-%m-%dT%H:%M:%SZ")
TAGS=${RELEASE_TAG:-$(gh api "repos/$GH_REPO/releases?per_page=20" --jq ".[] | select(.published_at >= \"$CUTOFF\" and ((.body // \"\") | contains(\"## Release Verification: ✅ Verified\") | not)) | .tag_name")}
FAILED=0
for TAG in $TAGS; do
./dev/google-cloud release:verify "$TAG" --update-release -t "$GH_TOKEN" || FAILED=1
done
exit $FAILED
- name: Create or update issue if previous step fails
if: ${{ failure() && github.ref == 'refs/heads/main' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
ROW="| $(date -u +'%Y-%m-%d %H:%M UTC') | [#$GITHUB_RUN_ID]($GITHUB_SERVER_URL/$GH_REPO/actions/runs/$GITHUB_RUN_ID) |"
ISSUE=$(gh issue list --repo "$GH_REPO" --search '"Release verification failed" in:title' --state open --json number,body --jq '.[0] // empty')
if [ -z "$ISSUE" ]; then
BODY=$(printf '`release:verify` failed for a recent release.\n\n@googleapis/cloud-sdk-php-team\n\n| Date | Workflow Run |\n| --- | --- |\n%s' "$ROW")
gh issue create \
--repo "$GH_REPO" \
--title "Release verification failed" \
--label ":rotating_light: critical" \
--body "$BODY"
else
NUM=$(jq -r '.number' <<<"$ISSUE")
BODY=$(jq -r '.body' <<<"$ISSUE")
[[ "$BODY" == *"| Date | Workflow Run |"* ]] || BODY="$BODY"$'\n\n| Date | Workflow Run |\n| --- | --- |'
gh api "repos/$GH_REPO/issues/$NUM" -X PATCH -f body="$BODY"$'\n'"$ROW"
fi
- name: Close issue if previous step succeeds
if: ${{ success() && github.ref == 'refs/heads/main' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
gh issue list --repo "$GH_REPO" --search '"Release verification failed" in:title' --state open --json number --jq '.[0].number // empty' \
| xargs -r -I{} gh issue close {} --repo "$GH_REPO" --comment "Release verification passed. Logs: $GITHUB_SERVER_URL/$GH_REPO/actions/runs/$GITHUB_RUN_ID"