Merge pull request #192 from bcgov/DEVX1881-CreateEvent #4
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: Build and update gitops repo | |
env: | |
TARGET_FILE: 'values.dev.yaml' | |
WORKING_DIR: 'developer-portal' | |
YAML_PROPERTY_PATH: '.upstream.backstage.image.tag' | |
HUSKY: 0 | |
on: | |
push: | |
paths-ignore: | |
- '.github/**' | |
- 'README.md' | |
- '.husky/**' | |
- 'catalog-info.yaml' | |
- '**/*.md' | |
- 'examples/**' | |
branches: ['main'] | |
# save resources. Don't take up a queue space doing a duplicate build | |
concurrency: | |
group: ci-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
call-build-workflow: | |
uses: ./.github/workflows/build.yaml | |
get-short-sha: | |
uses: ./.github/workflows/get-short-sha.yaml | |
update-gitops-file: | |
runs-on: ubuntu-latest | |
needs: [call-build-workflow, get-short-sha] | |
steps: | |
- name: Setup gitops repo access | |
uses: webfactory/ssh-agent@v0.9.0 | |
with: | |
ssh-private-key: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }} | |
- name: Checkout CD repo | |
uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }} | |
repository: ${{ secrets.MANIFEST_REPO }} | |
- name: 'Configure git' | |
# From https://github.com/orgs/community/discussions/26560#discussioncomment-3531273 | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
- name: Update image tag | |
run: | | |
cd ${{ env.WORKING_DIR }} | |
yq -i '${{ env.YAML_PROPERTY_PATH }} = "${{ needs.get-short-sha.outputs.SHORT_SHA }}"' ${{ env.TARGET_FILE }} | |
- name: Commit and push update | |
run: | | |
git commit -am "Update image tag for dev" | |
git push origin |