Push new image to Docker registry #4
Workflow file for this run
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: Continuous Deployment | |
on: | |
pull_request: | |
types: [closed] | |
branches: ['master', 'v2/master'] | |
env: | |
IMAGE_NAME: tafseer_api | |
jobs: | |
release: | |
name: "GitHub Release & Docker Hub Push" | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged == true | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Get version | |
id: get_version | |
run: | | |
echo ::set-output name=VERSION::$(cat git-version) | |
- name: Bump version and create tag | |
id: bump_version | |
uses: mathieudutour/github-tag-action@v5.6 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
default_bump: patch | |
release_branches: master,v2/master | |
custom_tag: ${{ steps.get_version.outputs.VERSION }} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.bump_version.outputs.new_tag }} | |
release_name: Release ${{ steps.bump_version.outputs.new_tag }} | |
draft: false | |
prerelease: false | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1.10.0 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }} |