Build and push to Docker Hub #130
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: 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/main' | |
shell: bash | |
run: echo "DOCKER_TAG=latest" >> $GITHUB_ENV | |
- name: Get branch for all other branches | |
if: github.ref != 'refs/heads/main' | |
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/chromedriver:${{ env.DOCKER_TAG }} |