Skip to content

Commit 6d7c981

Browse files
committed
fix(actions/flux-localhost-build): signed commits
1 parent 1e7facf commit 6d7c981

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

.github/workflows/flux-localhost-build.yaml

+25-9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
env:
2020
# renovate: datasource=docker depName=ghcr.io/fluxcd/flux-manifests
2121
FLUX_VERSION: "2.2.3"
22+
OUTFILE: "kube/bootstrap/flux/flux-install-localhost-manifests.yaml"
2223

2324
jobs:
2425
flux-localhost-build:
@@ -35,7 +36,7 @@ jobs:
3536
run: |
3637
echo "FLUX_VERSION=${{ github.event.inputs.version || env.FLUX_VERSION }}" >> "${GITHUB_ENV}"
3738
echo "BRANCH=flux-localhost-build-${{ github.event.inputs.version || env.FLUX_VERSION }}" >> "${GITHUB_ENV}"
38-
echo "MESSAGE=feat(bootstrap/flux)!: build Flux v${{ env.FLUX_VERSION }} localhost install manifests" >> "${GITHUB_ENV}"
39+
echo "MESSAGE=feat(bootstrap/flux)!: build Flux v${{ github.event.inputs.version || env.FLUX_VERSION }} localhost install manifests" >> "${GITHUB_ENV}"
3940
4041
- name: "Generate Short Lived OAuth App Token (ghs_*)"
4142
uses: actions/create-github-app-token@a0de6af83968303c8c955486bf9739a57d23c7f1 # v1.10.0
@@ -62,16 +63,31 @@ jobs:
6263
git config push.autoSetupRemote true
6364
git config user.name "${{ secrets.BOT_USERNAME }}[bot]"
6465
git config user.email "${{ secrets.BOT_API_ID }}+${{ secrets.BOT_USERNAME }}[bot]@users.noreply.github.com" # get $BOT_API_ID from `curl -s 'https://api.github.com/users/$(BOT_USERNAME)%5Bbot%5D' | yq .id`
65-
6666
git checkout -b ${{ env.BRANCH }} main
67-
#git checkout ${{ env.BRANCH }} || git checkout -b ${{ env.BRANCH }} main
68-
#git pull --rebase --autostash origin ${{ env.BRANCH }} || true
67+
git push origin ${{ env.BRANCH }} --force
6968
7069
mkdir -p /tmp/flux
7170
flux pull artifact oci://ghcr.io/fluxcd/flux-manifests:v${{ env.FLUX_VERSION }} --output /tmp/flux/
72-
flux build kustomization zzz-flux --path /tmp/flux --kustomization-file ./kube/clusters/biohazard/flux/flux-install-localhost.yaml --dry-run | tee ./kube/bootstrap/flux/flux-install-localhost-manifests.yaml
71+
flux build kustomization zzz-flux --path /tmp/flux --kustomization-file ./kube/clusters/biohazard/flux/flux-install-localhost.yaml --dry-run | tee ./${{ env.OUTFILE }}
7372
74-
git add ./kube/bootstrap/flux/flux-install-localhost-manifests.yaml
75-
git commit --message "${{ env.MESSAGE }}"
76-
git push origin ${{ env.BRANCH }} --force
77-
gh pr create --title "${{ env.MESSAGE }}" --body "Updates Flux install manifests, patched for use with localhost hostNetwork, to the ${{ env.FLUX_VERSION }} version." --reviewer ${{ github.repository_owner }}
73+
74+
# below is yoinked from https://gist.github.com/swinton/03e84635b45c78353b1f71e41007fc7c
75+
- name: Commit Changes # with commit signing
76+
shell: bash
77+
env:
78+
GH_TOKEN: "${{ steps.oauth-token.outputs.token }}"
79+
GITHUB_TOKEN: "${{ steps.oauth-token.outputs.token }}"
80+
FILE_TO_COMMIT: "${{ env.OUTFILE }}"
81+
DESTINATION_BRANCH: "${{ env.BRANCH }}"
82+
run: |
83+
export MESSAGE="${{ env.MESSAGE }}"
84+
export SHA=$( git rev-parse ${{ env.DESTINATION_BRANCH }}:${{ env.FILE_TO_COMMIT }} )
85+
export CONTENT=$( base64 -i ${{ env.FILE_TO_COMMIT }} )
86+
gh api --method PUT /repos/:owner/:repo/contents/${{ env.FILE_TO_COMMIT }} \
87+
--field message="${MESSAGE}" \
88+
--field content="${CONTENT}" \
89+
--field encoding="base64" \
90+
--field branch="${{ env.DESTINATION_BRANCH }}" \
91+
--field sha="${SHA}" \
92+
|| echo "No changes to push or errored pushing."
93+
gh pr create --base main --head ${{ env.BRANCH }} --title "${{ env.MESSAGE }}" --body "Updates Flux install manifests, patched for use with localhost hostNetwork, to the ${{ env.FLUX_VERSION }} version." --reviewer ${{ github.repository_owner }}

0 commit comments

Comments
 (0)