shari-sushi / 0015Laboratory

My SandBox, PoC
0 stars 0 forks source link

isseuの定期自動生成 #43

Open shari-sushi opened 2 months ago

shari-sushi commented 2 months ago
shari-sushi commented 2 months ago
無駄骨

# 結果…失敗 日時取得は成功してるっぽいけど、警告出てる。 ``` Run echo "::set-output name=now::$(date "+%m/%d")" Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ ``` 2022年に公式でset-output`は削除宣言されてる。2023年7 月時点で使ってる人が多いから消すの延期してるらしい。 修正します。 ``` Run actions-ecosystem/action-create-issue@v1 with: github_token: *** title: 【07/1[3](https://github.com/shari-sushi/0015Laboratory/actions/runs/9921682040/job/27409901137#step:3:3) (火)】定例 body: 自動生成された定例MTGのissueです。 labels: documentation repo: shari-sushi/001[5](https://github.com/shari-sushi/0015Laboratory/actions/runs/9921682040/job/27409901137#step:3:5)Laboratory Error: HttpError: Resource not accessible by integration Error: Resource not accessible by integration ``` わかんねぇ Claude3的にはtoken取得方法がダメらしい???

shari-sushi commented 2 months ago

また失敗… これか https://zenn.dev/tatsugon/articles/github-actions-permission-error repositoryのworkflowの設定からGITHUB_TOKENにwriteを許可しないとだめらしい。

shari-sushi commented 2 months ago

.github\workflows\create_weekly_mtg_issue.yml

name: Weekly MTG
on:
  schedule:
    - cron: 45 19 * * 0 # at 4:45 Mon(JST)
    - cron: 50 19 * * 0 # at 4:50 Mon(JST)

jobs:
  create_issue:
    name: Create team sync issue
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - name: Create team sync issue
        run: |
          new_issue_url=$(gh issue create \
            --title "$TITLE" \
            --label "$LABELS" \
            --body "$BODY")
          if [[ $PINNED == true ]]; then
            gh issue pin "$new_issue_url"
          fi
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GH_REPO: ${{ github.repository }}
          TITLE: 【(○曜日)】MTG 
          LABELS: documentation
          BODY: |
            自動生成issueです
          PINNED: true

# GitHub 公式より
# https://docs.github.com/en/actions/managing-issues-and-pull-requests/scheduling-issue-creation   

で2024/07/15 4:50に作成された。 このやり方(公式)なら遅延ないのか。

shari-sushi commented 2 months ago

次、日付取得してtitleに埋め込みたい

$ export NOW=`(TZ='Asia/Tokyo' date +'%m/%d(%a)')`
$ echo $NOW
07/15(Mon)

手元でやったらこんな感じで目的の日付データに加工できた ※Ubuntu 22.04.3 on windows

その値を環境変数に保存して、titelのjobで取り出すっぽい。

ただ、

shari-sushi commented 2 months ago

結果

https://github.com/shari-sushi/0015Laboratory/actions/runs/9930609591/job/27429535032 image

こっち↓、環境変数使わずに成功してたときの結果 https://github.com/shari-sushi/0015Laboratory/actions/runs/9930345970/job/27428973077 image

shari-sushi commented 2 months ago

できたー 環境変数誤字ってて、設定してない環境変数を読み込む=空文字状態になってたぽい