From c48bc91ffce47a20de7514f6d2597a68447eef2b Mon Sep 17 00:00:00 2001 From: Sean T Allen Date: Wed, 30 Aug 2023 09:58:36 -0400 Subject: [PATCH] Push images to GitHub Container Registry in addition to DockerHub (#9) --- .github/workflows/update-latest-image.yml | 57 ++++++++++++++++++---- .github/workflows/update-release-image.yml | 46 ++++++++++++----- Makefile | 7 ++- 3 files changed, 88 insertions(+), 22 deletions(-) diff --git a/.github/workflows/update-latest-image.yml b/.github/workflows/update-latest-image.yml index 494904e..072f698 100644 --- a/.github/workflows/update-latest-image.yml +++ b/.github/workflows/update-latest-image.yml @@ -17,15 +17,26 @@ jobs: steps: - name: Checkout source uses: actions/checkout@v3 - - name: Login to Docker Hub + - name: Login to DockerHub run: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" env: DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - - name: Build - run: make build-latest config=public - - name: Push - run: make push-latest config=public + - name: Build and push to DockerHub + run: | + make build-latest config=dockerhub + make push-latest config=dockerhub + - name: Login to GitHub Container Registry + # v2.2.0 + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push to GitHub Container Registry + run: | + make build-latest config=public + make push-latest config=public - name: Send alert on failure if: ${{ failure() }} uses: zulip/github-actions-zulip/send-message@b62d5a0e48a4d984ea4fce5dd65ba691963d4db4 @@ -45,7 +56,8 @@ jobs: - name: Checkout source uses: actions/checkout@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + # v2.2.0 + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -68,11 +80,11 @@ jobs: topic: ${{ github.repository }} scheduled job failure content: ${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }} failed. - prune-untagged-images: + prune-untagged-public-images: needs: - - rebuild-private-latest-image + - rebuild-public-latest-image - name: Prune untagged images + name: Prune untagged public images runs-on: ubuntu-latest steps: - name: Prune @@ -94,3 +106,30 @@ jobs: type: stream topic: ${{ github.repository }} scheduled job failure content: ${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }} failed. + + prune-untagged-private-images: + needs: + - rebuild-private-latest-image + + name: Prune untagged private images + runs-on: ubuntu-latest + steps: + - name: Prune + # v4.1.1 + uses: actions/delete-package-versions@0d39a63126868f5eefaa47169615edd3c0f61e20 + with: + package-name: 'library-documentation-action-v2-insiders' + package-type: 'container' + min-versions-to-keep: 1 + delete-only-untagged-versions: 'true' + - name: Send alert on failure + if: ${{ failure() }} + uses: zulip/github-actions-zulip/send-message@b62d5a0e48a4d984ea4fce5dd65ba691963d4db4 + with: + api-key: ${{ secrets.ZULIP_SCHEDULED_JOB_FAILURE_API_KEY }} + email: ${{ secrets.ZULIP_SCHEDULED_JOB_FAILURE_EMAIL }} + organization-url: 'https://ponylang.zulipchat.com/' + to: notifications + type: stream + topic: ${{ github.repository }} scheduled job failure + content: ${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }} failed. diff --git a/.github/workflows/update-release-image.yml b/.github/workflows/update-release-image.yml index 306ac23..3e6bb5a 100644 --- a/.github/workflows/update-release-image.yml +++ b/.github/workflows/update-release-image.yml @@ -17,15 +17,26 @@ jobs: steps: - name: Checkout source uses: actions/checkout@v3 - - name: Login to Docker Hub + - name: Login to DockerHub run: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" env: DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - - name: Build - run: make build-release config=public - - name: Push - run: make push-release config=public + - name: Build and Push to DockerHub + run: | + make build-release config=dockerhub + make push-release config=dockerhub + - name: Login to GitHub Container Registry + # v2.2.0 + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and Push to GitHub Container Registry + run: | + make build-release config=public + make push-release config=public - name: Send alert on failure if: ${{ failure() }} uses: zulip/github-actions-zulip/send-message@b62d5a0e48a4d984ea4fce5dd65ba691963d4db4 @@ -45,7 +56,8 @@ jobs: - name: Checkout source uses: actions/checkout@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + # v2.2.0 + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -82,12 +94,23 @@ jobs: env: DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - - name: Build - run: make build version="${VERSION}" config=public + - name: Build and Push to DockerHub + run: | + make build version="${VERSION}" config=dockerhub + make push version="${VERSION}" config=dockerhub env: VERSION: ${{ github.event.client_payload.version }} - - name: Push - run: make push version="${VERSION}" config=public + - name: Login to GitHub Container Registry + # v2.2.0 + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and Push to GitHub Container Registry + run: | + make build version="${VERSION}" config=public + make push version="${VERSION}" config=public env: VERSION: ${{ github.event.client_payload.version }} - name: Send alert on failure @@ -112,7 +135,8 @@ jobs: - name: Checkout source uses: actions/checkout@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + # v2.2.0 + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc with: registry: ghcr.io username: ${{ github.repository_owner }} diff --git a/Makefile b/Makefile index 408f4d3..67ffc25 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ config ?= public ifdef config - ifeq (,$(filter $(config),public private)) + ifeq (,$(filter $(config),public private dockerhub)) $(error Unknown configuration "$(config)") endif endif @@ -9,9 +9,12 @@ endif ifeq ($(config),private) IMAGE := ghcr.io/ponylang/library-documentation-action-v2-insiders PACKAGE = "git+https://${MATERIAL_INSIDERS_ACCESS}@github.com/squidfunk/mkdocs-material-insiders.git" -else +else ifeq ($(config),dockerhub) IMAGE = ponylang/library-documentation-action-v2 PACKAGE = "mkdocs-material" +else + IMAGE = ghcr.io/ponylang/library-documentation-action-v2 + PACKAGE = "mkdocs-material" endif all: pylint