ci: Publish Docker images (#41)

Co-authored-by: PalmDevs <git@palmdevs.me>
This commit is contained in:
oSumAtrIX
2024-07-13 14:57:29 +02:00
committed by GitHub
parent 09dc70632d
commit 5aeade122b
12 changed files with 257 additions and 1 deletions

79
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,79 @@
name: Release
on:
workflow_dispatch:
push:
branches:
- main
- dev
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Make sure the release step uses its own credentials:
# https://github.com/cycjimmy/semantic-release-action#private-packages
persist-credentials: false
fetch-depth: 0
- name: Cache dependencies
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: ${{ runner.os }}-bun-
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build packages
run: bun run build:packages
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: amd64, arm64
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and release
env:
DOCKER_REGISTRY_USER: ${{ github.actor }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }}
run: bunx multi-semantic-release
- name: Set Portainer stack webhook URL based on branch
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
PORTAINER_WEBHOOK_URL=${{ secrets.PORTAINER_WEBHOOK_MAIN_URL }}
else
PORTAINER_WEBHOOK_URL=${{ secrets.PORTAINER_WEBHOOK_DEV_URL }}
fi
echo "PORTAINER_WEBHOOK_URL=$PORTAINER_WEBHOOK_URL" >> $GITHUB_ENV
- name: Trigger Portainer stack update
uses: newarifrh/portainer-service-webhook@v1
with:
webhook_url: ${{ env.PORTAINER_WEBHOOK_URL }}
- name: Purge outdated images
uses: snok/container-retention-policy@v3.0.0
with:
account: ${{ github.actor }}
token: ${{ secrets.REPOSITORY_PUSH_ACCESS }}
image-names: "revanced-bot-*"
keep-n-most-recent: 5
cut-off: 3M