Skip to content

automatically push docker image to ghcr #2

automatically push docker image to ghcr

automatically push docker image to ghcr #2

Workflow file for this run

name: Build and Push Docker Image
on:
push:
paths:
- 'Dockerfile'
- 'VERSION'
pull_request:
paths:
- 'Dockerfile'
- 'VERSION'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read Gowin IDE version from VERSION file
id: version
run: |
VERSION=$(cat VERSION)
if [ -z "$VERSION" ]; then
echo "Error: VERSION file is empty or does not exist"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Using Gowin IDE version: $VERSION"
- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.version.outputs.version }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
build-args: |
GOWIN_VERSION=${{ steps.version.outputs.version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}