Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve code]: Formatterの自動適応Workflowの作成 #106

Merged
merged 3 commits into from
Apr 15, 2024

Conversation

nkte8
Copy link
Owner

@nkte8 nkte8 commented Apr 15, 2024

本PRではastro配下のコードを自動整形するworkflowを取り扱う。
本対応はあくまでastroディレクトリ配下のみの対応で、#65 の一部という扱いである

チェックする項目

  • PRリクエスト時にFormatterが自動適応され、必要に応じてcommitが追加されること
  • PRへコミットの追加時にFormatterが自動適応され、必要に応じてcommitが追加されること
  • PRをリオープン時、Formatterが自動適応され、必要に応じてcommitが追加されること
  • 本Workflowが実行される場合、Auto-manage PR branchesの後に実行されること ←あくまでPRリクエスト操作なので影響ないため、除外
  • [Improve code]: Formatterの自動適応Workflowの作成 #106 (comment) の課題を解決できなかったため、デプロイ時に修正・コミットを行うように変更

related Issue #65

@nkte8
Copy link
Owner Author

nkte8 commented Apr 15, 2024

synchronizeだと、PRのコメント(チェックボックスへの入力処理)にも反応してしまうらしい。適切な設定を探す必要あり

on:
  pull_request:
    types: ["opened", "synchronize", "reopened"]

@nkte8 nkte8 force-pushed the feature/issue_65 branch 2 times, most recently from 6899092 to 944f30f Compare April 15, 2024 10:13
Copy link

cloudflare-workers-and-pages bot commented Apr 15, 2024

Deploying skyshare with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8385694
Status: ✅  Deploy successful!
Preview URL: https://ca0ed2f5.skyshare.pages.dev
Branch Preview URL: https://feature-issue-65.skyshare.pages.dev

View logs

@nkte8
Copy link
Owner Author

nkte8 commented Apr 15, 2024

一旦コミットから fe14394 を削除、rebaseでコミットの結合・整形し、再度 Formatterが実行できるようにブランチを修正実施した

@nkte8
Copy link
Owner Author

nkte8 commented Apr 15, 2024

https://github.com/nkte8/skyshare/actions/runs/8687589376/job/23821413716
ログで出力されているコミットが異なる。

期待するデプロイブランチ: 4859d4d0a671d9582830ee3563bf4fcfc54f77d5
実際デプロイされてるブランチ: 195deab0666218f477d6775b2402d82fe451eb97

修正中

@nkte8
Copy link
Owner Author

nkte8 commented Apr 15, 2024

https://github.com/nkte8/skyshare/actions/runs/8687696499/job/23821737034
Refを明示したところ想定通りに動作

Commit: d7b83db934537ea029c2f78774639bbae51b7378

@nkte8
Copy link
Owner Author

nkte8 commented Apr 15, 2024

refを変更したことで、formatterによる変更が発生した場合に以下が正しく反映されなくなってしまった(shaが変わったことが原因?)

      - name: Add publish URL as commit status
        uses: actions/github-script@v7
        with:
          script: |
            const sha = context.payload.pull_request?.head.sha ?? context.sha;
            await github.rest.repos.createCommitStatus({
              owner: context.repo.owner,
              repo: context.repo.repo,
              context: 'Cloudflare Pages',
              description: 'Deploy to Cloudflare Pages: Click Details to see build result',
              state: 'success',
              sha,
              target_url: "${{ steps.published.outputs.pageurl }}",
            });

@nkte8
Copy link
Owner Author

nkte8 commented Apr 15, 2024

URLの表示OK
image
Commit StatusのCheck自体はCloudflareに実施してもらうとし、Workflowでの実施はしないで対応
image

@nkte8 nkte8 force-pushed the feature/issue_65 branch 4 times, most recently from f36eb73 to 8df347d Compare April 15, 2024 12:24
CheckoutするRefを明示

Commit Statusを削除

Cloudflare PagesのAlias URLを正しく出力するように修正

アクションするユーザをgithub-actionsユーザからworkflow実行者に修正
@nkte8
Copy link
Owner Author

nkte8 commented Apr 15, 2024

Cloudflare PagesのAlias URLは文字数が28文字超えた場合、後の文字列が削除されるため、これを設定する処理をWorkflowに追加

備考: Wrangler DeployではこのAlias URLの直接取得は現時点ではできない
cloudflare/workers-sdk#3717

@nkte8 nkte8 merged commit 6bfc320 into develop Apr 15, 2024
1 check passed
@nkte8 nkte8 deleted the feature/issue_65 branch April 15, 2024 12:32
nkte8 added a commit that referenced this pull request Apr 15, 2024
PR時に自動的にコードをフォーマットするワークフローを作成

フォーマッタをDeployへ統合

CheckoutするRefを明示

Commit Statusを削除

Cloudflare PagesのAlias URLを正しく出力するように修正

アクションするユーザをgithub-actionsユーザからworkflow実行者に修正

[Github Action] Format code at ./astro

---------

Co-authored-by: nkte8 <nkte8@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant