Skip to content

Merge branch 'main' of https://github.com/elct9620/GGJ2025 #163

Merge branch 'main' of https://github.com/elct9620/GGJ2025

Merge branch 'main' of https://github.com/elct9620/GGJ2025 #163

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v4
- name: Create Revision
id: revision
run: echo "value=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
preCommands: |
npm run tsc
command: |
deploy --dry-run --outdir=dist --define GIT_COMMIT_SHA:"\"${{ steps.revision.outputs.value }}\""
deploy --define GIT_COMMIT_SHA:"\"${{ steps.revision.outputs.value }}\""
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
wranglerVersion: "3.105.0"
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
sourcemaps: dist
ignore_missing: true
version: ${{ steps.revision.outputs.value }}
- name: Notify
uses: actions/github-script@v7
if: always()
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
with:
script: |
const { DISCORD_WEBHOOK_URL } = process.env;
// Configure content
var content = "";
if ('${{ job.status }}' === 'success') {
content = "# 🎉 版本更新完畢 `${{ steps.revision.outputs.value }}` by `" + context.payload.pusher.name + "` \n## 相關變更";
} else {
content = "# ❌ 版本更新失敗 `${{ steps.revision.outputs.value }}` by `" + context.payload.pusher.name + "` (`${{ job.status }}`)\n## 相關變更";
}
// Send a message to Discord
const res = await fetch(DISCORD_WEBHOOK_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
content,
embeds: context.payload.commits.map((commit) => ({
title: commit.id,
description: commit.message,
url: commit.url,
})),
}),
});