- auto-merge.yml
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
name: Auto Merge on: pull_request_review: types: [ submitted ] permissions: contents: write pull-requests: write id-token: write jobs: merge: if: ${{ github.event.review.state == 'approved' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Auto Merge env: GITHUB_TOKEN ${{ secrets.GITHUB_TOKEN }} run: | curl \ -X PUT \ -H "Authorization: token ${GITHUB_TOKEN}" \ -H "Accept: application/vnd.github.v3+json" \ -H "Content-Type: application/json" \ -d '{"commit_title": "Auto-merge: ${{ github.event.pull_request.title }}", "commit_message": "Auto-merged after approval", "sha": "${{ github.event.pull_request.head.sha }}", "merge_method": "squash"}' \ "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge" - name: Slack Failure if: ${{ failure() }} uses: rtCamp/action-slack-notify@v2 env: SLACK_TITLE: Auto Merge Failure SLACK_COLOR: danger SLACK_MESSAGE: "<!here> Auto merge failed in GitHub Actions :x:" SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_USERNAME: github-merge SLACK_CHANNEL: hoge SLACK_ICON: https://avatars.githubusercontent.com/u/44036562?s=280&v=4 |
リポジトリ > Settings > Pull Requests > Allow squash mergingにチェックすること。また、マージ後に別のワークフローを実行したい場合は以下のようにif文とトリガーを追加して、別ワークフローには workflow_dispatch: を追加する必要があることに注意。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
~省略~ actions: write - name: Trigger hoge if: success() uses: actions/github-script@v7 with: script: | console.log('Triggering hoge workflow...'); const result = await github.rest.actions.createWorkflowDispatch({ owner: context.repo.owner, repo: context.repo.repo, workflow_id: 'hoge.yml', ref: 'main' }); console.log('hoge workflow triggered successfully'); return result; |
Was this helpful?
0 / 0
1989年生まれのFindy/SRE サブマネージャー。ホスティングから大規模なアドテクなどのインフラエンジニアとして携わる。現在はサービスの信頼性向上、DevOps、可用性、レイテンシ、パフォーマンス、モニタリング、オブザーバビリティ、緊急対応、AWSでのインフラ構築、Docker開発環境の提供、IaC、新技術の検証、リファクタリング、セキュリティ強化、分析基盤の運用、チームマネジメントを担当している。
個人事業主では数社サーバー保守とベンチャー企業のインフラコンサルティングを行うほか、TechBullを創業し、未経験者向けにSREのコーチングやコミュニティ運営、LT大会の開催、 会員管理システム「Members」の開発をリードしている。さらに、エンジニア向けYouTubeメディア「TECH WORLD」ではSRE関連の動画に出演し、過去には脆弱性スキャナ「Vuls」のOSS活動にも貢献。