-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (64 loc) · 2.44 KB
/
ci-pr-trigger.yaml
File metadata and controls
74 lines (64 loc) · 2.44 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
###############################################################################
# GitOps PR Trigger — Demo
#
# Polls GHCR on a schedule for new image tags and creates a PR to update
# docker-compose.yaml when new versions are detected.
###############################################################################
name: "CI: Check for new releases"
on:
# schedule:
# - cron: "*/5 * * * *" # Uncomment to enable polling
workflow_dispatch: # Manual trigger only (safe for demo)
concurrency:
group: ci-pr-trigger
cancel-in-progress: true
jobs:
get-versions:
runs-on: ubuntu-latest
outputs:
backend_tag: ${{ steps.backend.outputs.tag }}
frontend_tag: ${{ steps.frontend.outputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Get latest backend tag
id: backend
uses: ./.github/actions/ghcr-latest-tag
with:
image: "aquasecurity/trivy"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get latest frontend tag
id: frontend
uses: ./.github/actions/ghcr-latest-tag
with:
image: "aquasecurity/trivy"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Log discovered versions
run: |
echo "Backend: ${{ steps.backend.outputs.tag }}"
echo "Frontend: ${{ steps.frontend.outputs.tag }}"
gitops_pr:
needs: get-versions
if: needs.get-versions.outputs.backend_tag != '' || needs.get-versions.outputs.frontend_tag != ''
uses: ./.github/workflows/ci-create-release-pr.yaml
with:
baseBranch: "main"
backendTag: ${{ needs.get-versions.outputs.backend_tag }}
frontendTag: ${{ needs.get-versions.outputs.frontend_tag }}
envPath: "projects/demo-app/.env"
secrets: inherit
cleanup:
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
steps:
- name: Delete old successful scheduled runs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO="${{ github.repository }}"
WORKFLOW_ID="${{ github.workflow }}"
# Get completed successful runs (skip the current one)
gh api "repos/${REPO}/actions/workflows/${WORKFLOW_ID}/runs?status=completed&conclusion=success&per_page=100" \
--jq ".workflow_runs[] | select(.id != ${{ github.run_id }}) | .id" | while read -r id; do
echo "Deleting run ${id}"
gh api -X DELETE "repos/${REPO}/actions/runs/${id}" || true
done