DockerHub #7
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: DockerHub | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- master | |
tags: | |
- 'v*.*.*' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
IMAGE_NAME: index.docker.io/metacall/cli | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build Docker Image | |
run: docker build --build-arg DISABLE_CACHE=`date +%s` -t metacall/cli -f Dockerfile . | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
run: docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" -p "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}" | |
- name: Push MetaCall CLI Docker Image to DockerHub | |
if: github.event_name != 'pull_request' | |
run: | | |
docker tag metacall/cli ${{ env.IMAGE_NAME }}:latest | |
docker push ${{ env.IMAGE_NAME }}:latest | |
if [[ "${{ contains(github.ref, 'refs/tags/') }}" = true ]]; then | |
TAG=${GITHUB_REF#refs/*/} | |
VERSION=${TAG#v} | |
docker tag metacall/cli ${{ env.IMAGE_NAME }}:${VERSION} | |
docker push ${{ env.IMAGE_NAME }}:${VERSION} | |
fi | |
- name: Logout from DockerHub | |
if: github.event_name != 'pull_request' | |
run: docker logout |