This repository has been archived by the owner on Feb 25, 2025. It is now read-only.
Initial commit #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Version & Docker Build And Push | |
on: | |
push: | |
tags: | |
- 'v*' | |
branches: | |
- 'beta' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
update-version: | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
commit_sha: ${{ steps.get_sha.outputs.sha }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PAT_TOKEN }} | |
- name: Update Version | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/v} | |
sed -i "s/const VERSION = '.*'/const VERSION = '$VERSION'/" index.js | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add index.js | |
git commit -m "chore: update version to $VERSION" | |
git push origin HEAD:main | |
- name: Get commit SHA | |
id: get_sha | |
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
build-and-push: | |
needs: [update-version] | |
if: | | |
always() && | |
(needs.update-version.result == 'success' || needs.update-version.result == 'skipped') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
steps: | |
- name: Determine ref | |
id: determine_ref | |
run: | | |
if [[ "${{ needs.update-version.result }}" == "skipped" ]]; then | |
echo "ref=beta" >> $GITHUB_OUTPUT | |
else | |
echo "ref=${{ needs.update-version.outputs.commit_sha }}" >> $GITHUB_OUTPUT | |
fi | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.determine_ref.outputs.ref }} | |
fetch-depth: 0 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: 'arm64,amd64' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.PAT_TOKEN }} | |
- name: Extract metadata for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=beta,enable=${{ github.ref == 'refs/heads/beta' }} | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=sha | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64,linux/arm64 | |
provenance: false | |
sbom: false | |
build-args: | | |
BUILDKIT_STEP_LOG_MAX_SIZE=10485760 | |
BUILDKIT_STEP_LOG_MAX_SPEED=10485760 |