From 64b27095635ad0e85e1e89ca85e186fabd0cd4b8 Mon Sep 17 00:00:00 2001 From: Patrick Meade Date: Fri, 21 Jun 2024 21:22:02 -0500 Subject: [PATCH] Publish Docker images to GitHub Container Registry --- .github/workflows/build_linux.yml | 2 +- .github/workflows/build_windows.yml | 2 +- .github/workflows/publish_ghcr.yml | 50 +++++++++++++++++++ .../workflows/{ => retired}/cr_publish.yml | 0 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish_ghcr.yml rename .github/workflows/{ => retired}/cr_publish.yml (100%) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index dfdb11172f..0fbca391e1 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -12,7 +12,7 @@ on: jobs: build_linux: - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ${{ !contains(github.event.head_commit.message, '[ci skip]') }} name: "Build (Linux)" runs-on: ubuntu-latest steps: diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 393db0c6d5..8e69861306 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -12,7 +12,7 @@ on: jobs: test_windows: - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ${{ !contains(github.event.head_commit.message, '[ci skip]') }} name: "Build (Windows)" runs-on: windows-latest steps: diff --git a/.github/workflows/publish_ghcr.yml b/.github/workflows/publish_ghcr.yml new file mode 100644 index 0000000000..4bbc5db37b --- /dev/null +++ b/.github/workflows/publish_ghcr.yml @@ -0,0 +1,50 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + publish: + if: ${{ !contains(github.event.head_commit.message, '[ci skip]') }} + name: "Publish to GitHub Container Registry" + runs-on: ubuntu-latest + steps: + - name: Checkout Project + uses: actions/checkout@v3 + + - name: Docker Meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/starfly-13/starfly-13 + # add git short SHA as Docker tag + tags: | + # branch event + type=ref,event=branch + # pull request event + type=ref,event=pr + # full length sha + type=sha,format=long + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + if: ${{ github.event_name != 'pull_request' }} + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push Docker Image + uses: docker/build-push-action@v4 + with: + context: . + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + push: ${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/cr_publish.yml b/.github/workflows/retired/cr_publish.yml similarity index 100% rename from .github/workflows/cr_publish.yml rename to .github/workflows/retired/cr_publish.yml