Created
December 2, 2021 15:18
-
-
Save mwakok/b40996282df82f3566261ff0b2a51b1a to your computer and use it in GitHub Desktop.
Workflow to publish on DockerHub
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 DockerHub | |
on: | |
release: | |
types: [published] | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v1 | |
- name: Get current version | |
id: vars | |
run: echo ::set-output name=version::$(cat setup.cfg | sed -n '2 p' | tail -c 6) | |
- name: Test output | |
run: echo ${{ steps.vars.outputs.version }} | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/image:${{ steps.vars.outputs.version }}, ${{ secrets.DOCKER_HUB_USERNAME }}/image:latest | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment