Skip to content

Commit a11c7f8

Browse files
committed
ci: 🏗️ add workflow to trigger build for latest tag
Adds a scheduled workflow (twice daily) and manual trigger to identify the latest semantic version tag and dispatch the build-and-deploy workflow for that reference.
1 parent 9b5d0ed commit a11c7f8

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Trigger Build and Deploy for Latest Tag
3+
4+
on:
5+
schedule:
6+
- cron: '0 0,12 * * *'
7+
workflow_dispatch:
8+
9+
permissions:
10+
actions: write
11+
contents: read
12+
13+
jobs:
14+
trigger-build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Generate GitHub App token
18+
id: app_token
19+
uses: actions/create-github-app-token@v3
20+
with:
21+
app-id: ${{ secrets.WORKFLOW_APP_ID }}
22+
private-key: ${{ secrets.WORKFLOW_APP_PRIVATE_KEY }}
23+
24+
- name: Find latest version tag
25+
id: latest_tag
26+
env:
27+
GH_TOKEN: ${{ steps.app_token.outputs.token }}
28+
REPO: ${{ github.repository }}
29+
run: |
30+
latest_tag="$({
31+
gh api "repos/${REPO}/tags" --paginate --jq '.[].name' || exit 1
32+
} | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' | sort -V | tail -n 1)"
33+
34+
if [[ -z "$latest_tag" ]]; then
35+
echo "No version tags found."
36+
exit 1
37+
fi
38+
39+
echo "tag=v${latest_tag}" >> "$GITHUB_OUTPUT"
40+
41+
- name: Trigger build-and-deploy workflow
42+
env:
43+
GH_TOKEN: ${{ steps.app_token.outputs.token }}
44+
REPO: ${{ github.repository }}
45+
TAG: ${{ steps.latest_tag.outputs.tag }}
46+
run: |
47+
gh workflow run build-and-deploy.yml --repo "$REPO" --ref "$TAG"

0 commit comments

Comments
 (0)