mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
41 lines
1.3 KiB
YAML
41 lines
1.3 KiB
YAML
name: Update Docker image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- '*' # This triggers the action on all tag pushes
|
|
|
|
jobs:
|
|
publish-docker-image:
|
|
if: github.repository_owner == 'gbdev'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push the master container image
|
|
run: |
|
|
COMMIT_HASH=$(git rev-parse --short HEAD)
|
|
sed -i "2i LABEL org.opencontainers.image.description=\"RGBDS container image, containing the git version master:$COMMIT_HASH\"" Dockerfile
|
|
docker build . --tag ghcr.io/gbdev/rgbds:master
|
|
docker push ghcr.io/gbdev/rgbds:master
|
|
|
|
- name: Tag release container image
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
TAG_NAME=${GITHUB_REF#refs/tags/}
|
|
sed -i "2i LABEL org.opencontainers.image.description=\"RGBDS container image for version $TAG_NAME\"" Dockerfile
|
|
docker build . --tag ghcr.io/gbdev/rgbds:$TAG_NAME
|
|
docker push ghcr.io/gbdev/rgbds:$TAG_NAME
|