Skip to content

Commit 0628513

Browse files
authored
Add new ArgoCD deploy action (#92)
* add action to update the image tag to deploy This will trigger ArgoCD to deploy (if configured to do so) * correctly ref ops_repository input * remove unused tag input * correctly skip deploy if not pushing to main Will uncomment after testing * rename vars and move to org-level instead of inputs * allow action to be triggered manually * enforce conditional * remove unused workflow_dispatch config * last check to make sure action works * Revert "last check to make sure action works" This reverts commit 47ad481. * no going back now
1 parent f959a19 commit 0628513

File tree

2 files changed

+83
-141
lines changed

2 files changed

+83
-141
lines changed

.github/workflows/deploy.yaml

Lines changed: 0 additions & 141 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Update Deploy Values
2+
on:
3+
workflow_call:
4+
inputs:
5+
ops_repository:
6+
required: true
7+
type: string
8+
description: "The ops repository to update (typically, notch8/<repo_name>_ops)"
9+
10+
jobs:
11+
update-deploy-tag:
12+
runs-on: ubuntu-latest
13+
if: inputs.ops_repository != '' && github.event_name == 'push' && github.ref == 'refs/heads/main'
14+
15+
steps:
16+
- id: setup
17+
name: Setup
18+
uses: notch8/actions/[email protected]
19+
with:
20+
token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }}
21+
22+
- uses: actions/create-github-app-token@v2
23+
id: app-token
24+
with:
25+
app-id: ${{ vars.OPS_REPO_WRITER_APP_ID }}
26+
private-key: ${{ secrets.OPS_REPO_WRITER_APP_PRIVATE_KEY }}
27+
owner: ${{ github.repository_owner }}
28+
29+
- name: Checkout ops repository
30+
uses: actions/checkout@v4
31+
with:
32+
repository: ${{ inputs.ops_repository }}
33+
token: ${{ steps.app-token.outputs.token }}
34+
path: ops-repo
35+
fetch-depth: 1
36+
persist-credentials: false
37+
38+
- name: Update Helm values file
39+
run: |
40+
cd ops-repo
41+
42+
for values_file in $(find . -type f -name "values.yaml"); do
43+
cp $values_file ${values_file}.backup
44+
45+
sed -i "s|tag: .*|tag: ${TAG}|g" $values_file
46+
47+
echo "=== Changes made to $values_file ==="
48+
diff -u ${values_file}.backup $values_file || true
49+
50+
rm ${values_file}.backup
51+
done
52+
53+
- name: Commit and push changes
54+
run: |
55+
cd ops-repo
56+
57+
git config --local user.email "[email protected]"
58+
git config --local user.name "GitHub Action"
59+
60+
# Check if there are changes to commit
61+
if git diff --quiet; then
62+
echo "No changes to commit"
63+
exit 0
64+
fi
65+
66+
find . -type f -name "values.yaml" -exec git add {} +
67+
git commit -m "Update image tag to ${TAG}
68+
69+
Source: ${{ github.repository }}@${TAG}
70+
Triggered by: ${{ github.event_name }}
71+
Actor: ${{ github.actor }}"
72+
73+
git remote set-url origin \
74+
https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${{ inputs.ops_repository }}.git
75+
git push origin main
76+
77+
- name: Summary
78+
run: |
79+
echo "✅ Successfully updated Helm values file(s)"
80+
echo "Repository: ${{ inputs.ops_repository }}"
81+
echo "Commit hash: ${TAG}"
82+
echo "Deploy with ArgoCD here:"
83+
echo "🚀 https://argo.notch8.cloud"

0 commit comments

Comments
 (0)