Update-Flux #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update-Flux | |
on: | |
workflow_dispatch: | |
jobs: | |
update-flux: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Flux CLI | |
uses: fluxcd/flux2/action@main | |
with: | |
version: "latest" | |
- name: Update flux | |
run: flux install --export > ./kubernetes/infra/flux/gotk-components.yaml | |
- name: Commit and push changes | |
run: | | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
if [ -n "$(git status --porcelain)" ]; then | |
git add . | |
git commit -m "Update flux" | |
git checkout -b gh-actions/flux-update | |
git push --set-upstream origin gh-actions/flux-update | |
else | |
echo "No changes to commit." | |
echo "no changes" > /tmp/no-changes.txt | |
fi | |
shell: bash | |
- name: Check for changes | |
id: changes | |
run: | | |
if [ -f /tmp/no-changes.txt ]; then | |
echo "::set-output name=changes::false" | |
else | |
echo "::set-output name=changes::true" | |
fi | |
shell: bash | |
- name: Create Pull Request | |
if: steps.changes.outputs.changes == 'true' | |
run: gh pr create -B master -H gh-actions/flux-update --title 'Update Flux' --body 'Updates flux components using Flux CLI' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |