Publish Docker images #38
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
# This workflow uses secrets stored in a specific github environment called `dockerhub-publish`. | |
# It needs to be created in repository settings->environments | |
# Add the dockerhub username and password in secrets named: | |
# DOCKERHUB_USERNAME | |
# DOCKERHUB_PASSWORD | |
# Add the dockerhub repo path in a secret named: | |
# DOCKERHUB_REPO | |
# This workflow will use them automatically. | |
# FIXME: Refactor this workflow using matrix and the new docker args | |
name: Publish Docker images | |
on: workflow_dispatch | |
# TODO: put this back once the docker files work correctly | |
# release: | |
# types: [released] | |
jobs: | |
publish-image: | |
environment: dockerhub-publish | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ secrets.DOCKERHUB_REPO }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=raw,value=latest | |
flavor: | | |
latest=false | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
file: './Dockerfile' | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |