Build and push to Docker Hub #242
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 is a basic workflow to help you get started with Actions | |
name: Build and push to Docker Hub | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: ['*'] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
push_to_registry: | |
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 v1.10.0, sha1 is used for better security | |
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get docker tag for master | |
if: github.ref == 'refs/heads/master' | |
shell: bash | |
run: echo "DOCKER_TAG=latest" >> $GITHUB_ENV | |
- name: Get branch for all other branches | |
if: github.ref != 'refs/heads/master' | |
shell: bash | |
run: echo "DOCKER_TAG=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
# Uses v2.7.0, sha1 is used for better security | |
uses: docker/build-push-action@a66e35b9cbcf4ad0ea91ffcaf7bbad63ad9e0229 | |
with: | |
context: . | |
push: true | |
tags: intera/ci-php-ant:${{ env.DOCKER_TAG }},intera/docker-ci-php-ant:${{ env.DOCKER_TAG }} |