GitHub CodespacesでDenoで何か作る時に毎回設定忘れるのでメモです。
VS Code設定
.vscode/settings.json
settings.json
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true,
}
この辺入れてないとリンターエラーが
GitHub Actions
DenoをGitHub Actionsで動かしたい時はこちら
.github/workflows/deno.yml
name: 1日2回実行
on:
push:
branches: [ main ]
schedule:
- cron: '0 0,12 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
# - run: deno run https://deno.land/std/examples/welcome.ts
- name: run
run: NOTION_TOKEN=${{ secrets.NOTION_TOKEN }} NOTION_KADAI_TEISYUTSU_DB_ID=${{ secrets.NOTION_KADAI_TEISYUTSU_DB_ID }} deno task start
- name: git commit & push
run: |
git config core.filemode false
if ! git diff --exit-code --quiet
then
git add --update
git config user.name github-actions
git config user.email action@github.com
git commit -m "Commit by github-actions"
git push https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:${{github.ref}}
fi
deno.json
deno.json
の書き方、npm script的な使い方のところをよく使う
deno.json
{
"tasks": {
"start": "deno run --allow-read --allow-env --allow-net --allow-write main.ts",
"deploy": "git add . && git commit -m 'init' && git push origin main"
}
}
$ deno task start