Skip to content

Build and push to Docker Hub #307

Build and push to Docker Hub

Build and push to Docker Hub #307

Workflow file for this run

# 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 }}