wip #36
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: [ ] | |
pull_request: | |
branches: [ ] | |
permissions: | |
contents: read | |
deployments: write | |
packages: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- 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: Use Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install | |
- name: Lint | |
run: bun run lint | |
- name: Madge | |
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 | |
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 }}' | |
}) | |
}); |