Skip to content

update deployed image on merge to master #2

update deployed image on merge to master

update deployed image on merge to master #2

Workflow file for this run

name: Build container
on:
push:
branches:
- master
- staging
- prod
pull_request:
branches:
- master
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-22.04
name: Docker Push
steps:
- uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Generate Auth Token
id: auth-token
uses: jamestrousdale/[email protected]
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Build test image
id: docker-build-test
uses: docker/build-push-action@v5
with:
target: test
push: false
- name: Run Perl tests
run: docker run -i ${{ steps.docker-build-test.outputs.imageid }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }}
flavor: |
latest=false
tags: |
type=sha,format=long,priority=1000
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
- name: Update deployed image
if: contains( fromJSON(steps.meta.outputs.json).tags, "${{ github.repository }}:latest")
uses: aurelien-baudet/workflow-dispatch@v2
with:
repo: metacpan/metacpan-k8s
ref: main
workflow: set-image.yml
token: ${{ steps.auth-token.outputs.access-token }}
inputs: '{ "app": "api-v0-shim", "environment": "prod", "base-tag": "${{ github.repository }}:latest", "tag": "${{ fromJSON(steps.meta.outputs.json).tags[0] }}" }'