add docker build workflow #1
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 deployment container | |
on: | |
push: | |
branches: | |
- master | |
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: Build test image | |
uses: docker/build-push-action@v2 | |
with: | |
tags: metacpan/metacpan-api-v0-shim:test | |
target: test | |
push: false | |
- name: Run Perl tests | |
run: docker run -i metacpan/metacpan-api-v0-shim:test | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: metacpan/metacpan-api-v0-shim | |
flavour: | | |
latest=false | |
tags: | | |
type=sha | |
type=ref,event=branch | |
type=ref,event=pr | |
type=raw,value=latest,enable={{is_default_branch}} | |
- run: echo '${{ steps.meta.outputs.json }}' | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
annotations: ${{ steps.meta.outputs.annotations }} |