π Merge Template Sync PR #1 #3
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: π Release | |
on: | |
push: | |
branches: [ main, dev ] | |
pull_request: | |
branches: [ dev ] | |
permissions: | |
contents: read | |
deployments: write | |
packages: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout code | |
uses: actions/checkout@v4 | |
- name: πΎ Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.bun/install/cache | |
key: ${{ runner.os }}-${{ matrix.bun }}-bun-${{ hashFiles('**/bun.lockb') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.bun }}-bun- | |
- name: π₯ Setup Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: π¦ Install dependencies | |
run: bun install | |
- name: π§Ή Lint code | |
run: bun run lint | |
- name: πΈοΈ Check dependencies | |
run: bun run madge | |
- name: π Type check | |
run: bun run typecheck | |
- name: π·οΈ Set project name | |
run: echo "PROJECT_NAME=$(jq -r .name package.json)" >> $GITHUB_ENV | |
- name: π Deploy to Cloudflare | |
id: deploy | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
command: deploy --name=${{ env.PROJECT_NAME }} | |
- name: π’ Send deployment status | |
if: always() | |
uses: actions/github-script@v7 | |
env: | |
DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const status = '${{ steps.deploy.outcome }}' === 'success' ? 'success' : 'failure'; | |
await fetch("${{ secrets.DISCORD_DEPLOY_WEBHOOK }}", { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
content: status === 'failure' ? 'β ${{ env.PROJECT_NAME }} deployment failed' : 'π ${{ env.PROJECT_NAME }} has been released. ${{ env.DEPLOYMENT_URL }}' | |
}) | |
}); |