Add github action to build and publish Docker image #8
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 Publish Docker Image | |
on: | |
push: | |
branches: | |
- '*' | |
paths: | |
- 'snitch/docker/Dockerfile' | |
pull_request: | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
id: docker-buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and Push Docker Image | |
run: | | |
docker buildx build -t ghcr.io/${{ github.repository_owner }}/snitch-toolchain:${{ github.sha }} -f snitch/docker/Dockerfile . | |
docker push ghcr.io/${{ github.repository_owner }}/snitch-toolchain:${{ github.sha }} | |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
docker buildx imagetools create ghcr.io/${{ github.repository_owner }}/snitch-toolchain:${{ github.sha }} --tag ghcr.io/${{ github.repository_owner }}/snitch-toolchain:latest | |
docker push ghcr.io/${{ github.repository_owner }}/snitch-toolchain:latest | |
else | |
echo "Not on the main branch, skipping push to latest tag." | |
fi | |