From df325317702cea0d1317255e03c7b27e44e97d6b Mon Sep 17 00:00:00 2001 From: Ushie Date: Sun, 7 Jul 2024 21:28:04 +0300 Subject: [PATCH] build: Publish Docker images with semantic-release (#179) --- .github/workflows/release.yml | 44 ++++++++--------------------------- .releaserc | 22 ++++++++++++++---- 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ed8fcea..531a377 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,7 +35,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: "lts/*" - cache: 'npm' + cache: "npm" - name: Install dependencies run: npm install @@ -52,39 +52,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }} run: npm exec semantic-release - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - - - name: Extract metadata for the Docker image - id: metadata - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ env.IMAGE_NAME }} - flavor: | - latest=${{ startsWith(github.ref, 'refs/heads/main') }} - suffix=-${{ github.sha }} - - - 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 Docker image - id: build - uses: docker/build-push-action@v5 - with: - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max,ignore-error=true - push: true - tags: ${{ steps.metadata.outputs.tags }} - labels: ${{ steps.metadata.outputs.labels }} - build-args: | - GITHUB_ACTOR=${{ github.actor }} - GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} - - name: Set Portainer stack webhook URL based on branch run: | if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then @@ -98,3 +65,12 @@ jobs: uses: newarifrh/portainer-service-webhook@v1 with: webhook_url: ${{ env.PORTAINER_WEBHOOK_URL }} + + - name: Purge outdated images + uses: snok/container-retention-policy@v3 + with: + account: ${{ github.actor }} + token: ${{ secrets.GITHUB_TOKEN }} + image-names: "revanced-api" + keep-n-most-recent: 5 + cut-off: 3M diff --git a/.releaserc b/.releaserc index 193b3fb..756d3a4 100644 --- a/.releaserc +++ b/.releaserc @@ -23,7 +23,7 @@ "assets": [ "README.md", "CHANGELOG.md", - "gradle.properties", + "gradle.properties" ] } ], @@ -35,15 +35,27 @@ "path": "build/libs/*" } ], - successComment: false + "successComment": false + } + ], + [ + "@codedependant/semantic-release-docker", + { + "dockerImage": "revanced-api", + "dockerRegistry": "ghcr.io", + "dockerProject": "revanced", + "dockerPlatform": [ + "linux/amd64", + "linux/arm64/v8" + ] } ], [ "@saithodev/semantic-release-backmerge", { - backmergeBranches: [{"from": "main", "to": "dev"}], - clearWorkspace: true + "backmergeBranches": [{"from": "main", "to": "dev"}], + "clearWorkspace": true } ] ] -} +} \ No newline at end of file