try tags #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: Build and Push Docker Image | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- build | ||
tags: | ||
- '*' # Push events to all tags | ||
env: | ||
DOCKERHUB_USERNAME: jordotech | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
IMAGE_NAME: fastapi-slackbot | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Get branch or tag name | ||
id: branch_or_tag_name | ||
run: echo ::set-output name=name::${GITHUB_REF#refs/*/} | ||
- name: Determine tag | ||
id: image_tag | ||
run: | | ||
Check failure on line 33 in .github/workflows/build_and_push.yml
|
||
if [[ "${{ steps.branch_or_tag_name.outputs.name }}" == "tags"* ]]; then | ||
echo "::set-output name=tag::${{ steps.branch_or_tag_name.outputs.name#tags/ }}" | ||
else | ||
echo "::set-output name=tag::${{ github.sha }}" | ||
fi | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ env.DOCKERHUB_USERNAME }} | ||
password: ${{ env.DOCKERHUB_PASSWORD }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.branch_name.outputs.branch }} | ||