116 lines
2.9 KiB
YAML
116 lines
2.9 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
inputs:
|
|
deploy_worker:
|
|
description: Deploy the Worker to production
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
publish_oci:
|
|
description: Publish the OCI image to GHCR
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
|
|
concurrency:
|
|
group: release-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
validate:
|
|
permissions:
|
|
contents: read
|
|
uses: ./.github/workflows/validate-reusable.yml
|
|
|
|
deploy-worker:
|
|
needs:
|
|
- validate
|
|
if: >
|
|
needs.validate.result == 'success' &&
|
|
secrets.CLOUDFLARE_API_TOKEN != '' &&
|
|
secrets.CLOUDFLARE_ACCOUNT_ID != '' &&
|
|
(
|
|
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
|
|
(github.event_name == 'workflow_dispatch' && inputs.deploy_worker && github.ref == 'refs/heads/main')
|
|
)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
environment: production
|
|
permissions:
|
|
contents: read
|
|
env:
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Bun
|
|
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
|
|
with:
|
|
bun-version: 1.3.12
|
|
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
|
|
- name: Generate Worker types
|
|
run: bun run cf-typegen
|
|
|
|
- name: Deploy Worker
|
|
run: bun run deploy
|
|
|
|
publish-oci:
|
|
needs:
|
|
- validate
|
|
if: >
|
|
needs.validate.result == 'success' &&
|
|
(
|
|
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
|
|
(
|
|
github.event_name == 'workflow_dispatch' &&
|
|
inputs.publish_oci &&
|
|
github.ref == 'refs/heads/main'
|
|
)
|
|
)
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
env:
|
|
IMAGE_NAME: ghcr.io/xixu-me/paseo-relay
|
|
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and publish OCI image
|
|
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
provenance: true
|
|
sbom: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: ${{ env.IMAGE_NAME }}:main
|