mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
ci: run only the "build tagged container image" step on tag pushes
This commit is contained in:
10
.github/workflows/build-container.yml
vendored
10
.github/workflows/build-container.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Update Docker image
|
name: Build container image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -12,6 +12,7 @@ jobs:
|
|||||||
if: github.repository_owner == 'gbdev'
|
if: github.repository_owner == 'gbdev'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
# So that the workflow can write to the ghcr an upload there
|
||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
@@ -25,16 +26,19 @@ jobs:
|
|||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push the master container image
|
- name: Build and push the master container image
|
||||||
|
# When a commit is pushed to master
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
run: |
|
run: |
|
||||||
COMMIT_HASH=$(git rev-parse --short HEAD)
|
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
|
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 build . --tag ghcr.io/gbdev/rgbds:master
|
||||||
docker push ghcr.io/gbdev/rgbds:master
|
docker push ghcr.io/gbdev/rgbds:master
|
||||||
|
|
||||||
- name: Tag release container image
|
- name: Build and push the version-tagged container image
|
||||||
|
# When a tag is pushed
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: |
|
run: |
|
||||||
TAG_NAME=${GITHUB_REF#refs/tags/}
|
TAG_NAME=${GITHUB_REF#refs/tags/}
|
||||||
sed -i "2i LABEL org.opencontainers.image.description=\"RGBDS container image for version $TAG_NAME\"" Dockerfile
|
sed -i "2i LABEL org.opencontainers.image.description=\"RGBDS container image for the release version $TAG_NAME\"" Dockerfile
|
||||||
docker build . --tag ghcr.io/gbdev/rgbds:$TAG_NAME
|
docker build . --tag ghcr.io/gbdev/rgbds:$TAG_NAME
|
||||||
docker push ghcr.io/gbdev/rgbds:$TAG_NAME
|
docker push ghcr.io/gbdev/rgbds:$TAG_NAME
|
||||||
|
|||||||
Reference in New Issue
Block a user