Update build_and_push.yml #2
Workflow file for this run
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 Push Docker Images | |
on: | |
push: | |
# branches: | |
# - main | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository_owner }} | |
jobs: | |
build-and-push-file-watcher: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Check out code | |
uses: actions/[email protected] | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.WRITE_PACKAGE_TOKEN }} | |
- name: Build and push image | |
uses: docker/build-push-action@v5 | |
id: docker_build | |
with: | |
file: ./container/file_watcher.D | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/filewatcher:${{ github.sha }} | |
- name: Checkout the Gitops repository | |
uses: actions/checkout@v4 | |
with: | |
repository: fiaisis/gitops | |
token: ${{ secrets.GITOPS_STAGING_EDIT_TOKEN }} | |
- name: Remove sha256 from the builds digest | |
id: remove_sha256 | |
run: | | |
DIGEST=${{ steps.docker_build.outputs.digest }} | |
FILTERED_DIGEST=${DIGEST#sha256:} | |
echo "::set-output name=filtered-digest::$FILTERED_DIGEST" | |
- name: Edit the YAML file watcher file for staging | |
uses: mikefarah/[email protected] | |
with: | |
cmd: yq e -i '.spec.template.spec.containers[] |= (select(.name == "file-watcher-operator") | .env[] |= select(.name == "FILE_WATCHER_SHA256").value = "${{ steps.remove_sha256.outputs.filtered-digest }}")' './components/file-watcher-operator/overlays/staging/file-watcher-operator.yml' | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -am "Update file watcher to use ${{ steps.docker_build.outputs.digest }}" | |
git push | |
build-and-push-file-watcher-operator: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Check out code | |
uses: actions/[email protected] | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.WRITE_PACKAGE_TOKEN }} | |
- name: Build and push image | |
uses: docker/build-push-action@v5 | |
id: docker_build | |
with: | |
file: ./container/file_watcher_operator.D | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/filewatcher-operator:${{ github.sha }} | |
- name: Checkout the Gitops repository | |
uses: actions/checkout@v4 | |
with: | |
repository: fiaisis/gitops | |
token: ${{ secrets.GITOPS_STAGING_EDIT_TOKEN }} | |
- name: Edit the YAML file watcher operator file for staging | |
uses: mikefarah/[email protected] | |
with: | |
cmd: yq e -i '.spec.template.spec.containers[] |= select(.name == "file-watcher-operator").image = "ghcr.io/fiaisis/filewatcher-operator@${{ steps.docker_build.outputs.digest }}"' './components/file-watcher-operator/overlays/staging/file-watcher-operator.yml' | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -am "Update file-watcher-operator to use ${{ steps.docker_build.outputs.digest }}" | |
git push |