Skip to content

Update job_creator.Dockerfile #73

Update job_creator.Dockerfile

Update job_creator.Dockerfile #73

name: Build and Push Docker Images
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out code
uses: actions/checkout@v4
- 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: Checkout the Gitops repository
uses: actions/checkout@v4
with:
repository: fiaisis/gitops
token: ${{ secrets.GITOPS_STAGING_EDIT_TOKEN }}
- name: Build and push jobwatcher Docker image
id: jobwatcher_build
uses: docker/build-push-action@v5
with:
file: ./container/job_watcher.Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/jobwatcher:${{ github.sha }}
- name: Remove sha256 from the builds digest
id: remove_sha256_watcher
run: |
DIGEST=${{ steps.jobwatcher_build.outputs.digest }}
FILTERED_DIGEST=${DIGEST#sha256:}
echo "::set-output name=digest::$FILTERED_DIGEST"
- name: Build and push jobcreator Docker image
id: jobcreator_build
uses: docker/build-push-action@v5
with:
file: ./container/job_creator.Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/jobcreator:${{ github.sha }}
- name: Edit the YAML jobcreator.yml file for staging for jobwatcher
uses: mikefarah/[email protected]
with:
cmd: yq e -i '.spec.template.spec.containers[] |= (select(.name == "jobcreator") | .env[] |= select(.name == "WATCHER_SHA").value = "${{ steps.remove_sha256_watcher.outputs.digest }}")' './components/jobcreator/envs/staging/jobcreator.yml'
- name: Edit the YAML jobcreator.yml file for staging for jobcreator
uses: mikefarah/[email protected]
with:
cmd: yq e -i '.spec.template.spec.containers[] |= select(.name == "jobcreator").image = "ghcr.io/fiaisis/jobcreator@${{ steps.jobcreator_build.outputs.digest }}"' './components/jobcreator/envs/staging/jobcreator.yml'
- name: Commit and push changes for jobcreator/jobwatcher
continue-on-error: true
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -am "[CD] Update jobcreator/jobwatcher with this commit ${{ github.event.head_commit.url}}"
git push