Publish docker image #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: Publish docker image | |
on: | |
workflow_run: | |
workflows: ['CI'] | |
branches: [master] | |
types: | |
- completed | |
permissions: | |
contents: read | |
packages: write | |
env: | |
DOCKER_REGISTRY: ghcr.io | |
DOCKER_IMG_NAME: geoblocks/ngv-ui | |
DOCKER_TAG: latest | |
jobs: | |
build_and_publish: | |
name: Build and publish | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push ngv | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMG_NAME }}:${{ env.DOCKER_TAG }} | |
- name: Update images sha | |
id: get_image_sha | |
run: echo "img_sha=$(docker inspect --format='{{index .RepoDigests 0}}' '${DOCKER_REGISTRY}/${DOCKER_IMG_NAME}:${DOCKER_TAG}' | cut -d':' -f2)" >> $GITHUB_OUTPUT; | |
outputs: | |
image_sha: ${{ steps.get_image_sha.outputs.img_sha }} | |
trigger_deploy: | |
name: Trigger deploy on lab | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
needs: build_and_publish | |
steps: | |
- name: Deploy Stage | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GH_PAT_DEPLOY }} | |
script: | | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: 'camptocamp', | |
repo: 'argocd-gs-plg-apps', | |
workflow_id: 'update-ngv-image.yaml', | |
ref: 'main', | |
inputs: { | |
img_sha: '${{ needs.build_and_publish.outputs.img_sha }}' | |
} | |
}); |