Skip to content

Commit b810f40

Browse files
authored
chore: Update GitHub Actions workflow to pin trueforge SHA in truefoundry.yaml and push changes (#572)
1 parent f5dacd9 commit b810f40

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

‎.github/workflows/sync-devtest-commit.yml‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Sync commit to trueforge-devtest-deployment
22

3-
# Writes github.sha into trueforge-devtest-deployment/test.txt on main.
4-
# For pre-main testing: add your branch under push.branches (or use workflow_dispatch
5-
# once this file is on the default branch).
3+
# Pins github.sha into trueforge-devtest-deployment/truefoundry.yaml (both
4+
# components' image.build_source.ref) and pushes to main. That merge triggers
5+
# tfy-deploy in the deployment repo.
6+
# For pre-main testing: add your branch under push.branches.
67
on:
78
workflow_dispatch:
89
push:
@@ -17,7 +18,7 @@ permissions:
1718

1819
jobs:
1920
sync:
20-
name: Update test.txt with trueforge SHA
21+
name: Pin SHA and push
2122
runs-on: ubuntu-latest
2223
steps:
2324
- id: app-token
@@ -33,20 +34,33 @@ jobs:
3334
repository: truefoundry/trueforge-devtest-deployment
3435
token: ${{ steps.app-token.outputs.token }}
3536

36-
- name: Write commit SHA and push
37+
- name: Install yq
38+
run: |
39+
sudo wget -q https://github.com/mikefarah/yq/releases/download/v4.53.3/yq_linux_amd64 -O /usr/bin/yq
40+
sudo chmod +x /usr/bin/yq
41+
42+
- name: Pin trueforge SHA and push
3743
env:
3844
SHA: ${{ github.sha }}
45+
BRANCH: ${{ github.ref_name }}
3946
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
4047
run: |
4148
set -euo pipefail
49+
yq -i '
50+
(.components[] | select(.image.build_source.repo_url == "https://github.com/truefoundry/trueforge") |
51+
.image.build_source.ref) = strenv(SHA) |
52+
(.components[] | select(.image.build_source.repo_url == "https://github.com/truefoundry/trueforge") |
53+
.image.build_source.branch_name) = strenv(BRANCH)
54+
' truefoundry.yaml
4255
echo "$SHA" > test.txt
56+
4357
git config user.name "${APP_SLUG}[bot]"
4458
git config user.email "${APP_SLUG}[bot]@users.noreply.github.com"
45-
git add test.txt
59+
git add truefoundry.yaml test.txt
4660
if git diff --cached --quiet; then
47-
echo "test.txt already at $SHA"
61+
echo "Already pinned at $SHA"
4862
exit 0
4963
fi
5064
git commit -m "chore: pin trueforge@${SHA}"
5165
git push
52-
echo "Updated test.txt → \`$SHA\`" >> "$GITHUB_STEP_SUMMARY"
66+
echo "Pinned trueforge@\`$SHA\` on main" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)