Build and Push Docker Image #4
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: | |
workflow_run: | |
workflows: ["Go Test"] | |
types: | |
- completed | |
jobs: | |
build: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build Docker image | |
run: docker build -t ${{ secrets.DOCKER_USER }}/go-stack:${{ github.sha }} . | |
- name: Tag for latest | |
run: docker tag ${{ secrets.DOCKER_USER }}/go-stack:${{ github.sha }} ${{ secrets.DOCKER_USER }}/go-stack:latest | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push Docker images | |
run: docker push --all-tags ${{ secrets.DOCKER_USER }}/go-stack |