From 4f6487da6a29d79eb32a2a70cffcf09e05ce386d Mon Sep 17 00:00:00 2001 From: ABHAY PANDEY Date: Wed, 26 Aug 2026 10:27:24 +0530 Subject: [PATCH] ci: build and push container image after CI passes on main --- .../ci-publish-container-image-on-main.md | 8 +++ .github/workflows/publish-container-image.yml | 57 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .changeset/ci-publish-container-image-on-main.md create mode 100644 .github/workflows/publish-container-image.yml diff --git a/.changeset/ci-publish-container-image-on-main.md b/.changeset/ci-publish-container-image-on-main.md new file mode 100644 index 00000000..9be57893 --- /dev/null +++ b/.changeset/ci-publish-container-image-on-main.md @@ -0,0 +1,8 @@ +--- +"nostream": patch +--- + +ci: build and push container image to GHCR after CI passes on main + +Adds a GitHub Actions workflow that publishes `ghcr.io/cameri/nostream:main` and a +per-commit `sha-*` tag once the CI Checks workflow succeeds for pushes to `main`. diff --git a/.github/workflows/publish-container-image.yml b/.github/workflows/publish-container-image.yml new file mode 100644 index 00000000..434183ab --- /dev/null +++ b/.github/workflows/publish-container-image.yml @@ -0,0 +1,57 @@ +name: Publish Container Image + +on: + workflow_run: + workflows: + - CI Checks + types: + - completed + branches: + - main + workflow_dispatch: + +jobs: + build-and-push-image: + name: Build and push container image + if: > + github.event_name == 'workflow_dispatch' || + ( + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'push' + ) + runs-on: ubuntu-latest + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'workflow_dispatch' && github.ref || github.event.workflow_run.head_sha }} + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=main + type=sha,prefix=sha- + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}