Append COMMIT_SHORT_SHA to container image tag #17
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 Docker Image | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Log in to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: "${{ secrets.DOCKER_HUB_USERNAME }}" | |
password: "${{ secrets.DOCKER_HUB_TOKEN }}" | |
- name: Set Short Git Commit SHA | |
id: vars | |
run: | | |
SHORT_SHA=$(git rev-parse --short ${{ github.sha }}) | |
echo "COMMIT_SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: true | |
tags: "${{ secrets.DOCKER_HUB_USERNAME }}/telegraf:1.31.3-${{ env.COMMIT_SHORT_SHA }}" |