Skip to content

Use var for gh repo of the Docker image #4

Use var for gh repo of the Docker image

Use var for gh repo of the Docker image #4

Workflow file for this run

name: Build and Publish Docker Image
on:
push:
branches:
- '*'
paths:
- 'snitch/docker/Dockerfile'
pull_request:
jobs:
build-and-publish:
runs-on: ubuntu-latest
defaults:

Check failure on line 15 in .github/workflows/ci-docker.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/ci-docker.yml

Invalid workflow file

You have an error in your yaml syntax on line 15
run:
env:
SNITCH_TOOLCHAIN_REPO: snitch-toolchain
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
id: docker-buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Push Docker Image
run: |
docker buildx build -t ghcr.io/${{ github.repository_owner }}/${SNITCH_TOOLCHAIN_REPO}:${{ github.sha }} -f snitch/docker/Dockerfile .
docker push ghcr.io/${{ github.repository_owner }}/${SNITCH_TOOLCHAIN_REPO}:${{ github.sha }}
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
docker buildx imagetools create ghcr.io/${{ github.repository_owner }}/${SNITCH_TOOLCHAIN_REPO}:${{ github.sha }} --tag ghcr.io/${{ github.repository_owner }}/${SNITCH_TOOLCHAIN_REPO}:latest
docker push ghcr.io/${{ github.repository_owner }}/${SNITCH_TOOLCHAIN_REPO}:latest
else
echo "Not on the main branch, skipping push to latest tag."
fi