build: Publish Docker images with semantic-release (#179)

This commit is contained in:
Ushie 2024-07-07 21:28:04 +03:00 committed by oSumAtrIX
parent 1ec6999ddb
commit df32531770
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 27 additions and 39 deletions

View File

@ -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

View File

@ -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
}
]
]
}
}