Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/actions/create_pr/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
GITHUB_TOKEN:
description: 'GitHub token for authentication'
required: true
pr_number:
description: 'PR number to update'
required: false
default: 'unknown'

runs:
using: composite
Expand Down Expand Up @@ -47,7 +51,7 @@ runs:

gh pr comment $EXISTING_PR --body "新しい変更が $HEAD_BRANCH ブランチにマージされました。

この変更は元PR #${{ github.event.pull_request.number }} からのものです。
この変更は元PR #${{ inputs.pr_number }} からのものです。

$HEAD_BRANCH ブランチには新しい変更が含まれています。このPRをマージすると、これらの変更が $BASE_BRANCH に反映されます。"
else
Expand All @@ -63,5 +67,5 @@ runs:
## 含まれる変更点
このPRは最新の $HEAD_BRANCH ブランチの変更を $BASE_BRANCH に反映します。

マージ元PR: #${{ github.event.pull_request.number }}"
マージ元PR: #${{ inputs.pr_number }}"
fi
56 changes: 24 additions & 32 deletions .github/workflows/create-staging-pr.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,46 @@
name: Update Staging PR

on:
pull_request:
types: [closed]
workflow_run:
workflows:
- Deployment to dev
branches:
- dev
types:
- completed

jobs:
check-deploy-status:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
outputs:
deploy_success: ${{ steps.check-deploy.outputs.success }}
steps:
- name: Check deploy action status
id: check-deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# deploy_actionの最新の実行結果を確認
# ここでは特定のワークフロー名とブランチを指定
deploy_status=$(gh run list --workflow=deployment-dev.yml --branch dev --limit 1 --json conclusion --jq '.[0].conclusion')

echo "最新のdeploy_actionの状態: $deploy_status"

if [ "$deploy_status" = "success" ]; then
echo "success=true" >> $GITHUB_OUTPUT
echo "デプロイは成功しています。PRの作成/更新を進めます。"
else
echo "success=false" >> $GITHUB_OUTPUT
echo "デプロイは成功していません。PRの作成/更新をスキップします。"
fi

update-staging-pr:
# デプロイが成功していた場合のみ実行
needs: check-deploy-status
if: needs.check-deploy-status.outputs.deploy_success == 'true'
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
outputs:
deploy_success: ${{ steps.check-deploy.outputs.success }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # すべての履歴を取得(ブランチの比較に必要)

- name: Get PR information from deployment
id: pr-info
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
run: |
# 元のワークフローを起動したPRの情報を取得
PR_NUMBER=$(gh api /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/attempts/latest -q '.pull_requests[0].number')

if [ -n "$PR_NUMBER" ]; then
echo "元のデプロイを起動したPR番号: $PR_NUMBER"
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
else
echo "PRの情報が見つかりません。直接プッシュなどの可能性があります。"
echo "pr_number=unknown" >> $GITHUB_OUTPUT
fi

- uses: ./.github/actions/create_pr
id: create_pr
with:
base_branch: staging
head_branch: dev
pr_number: ${{ steps.pr-info.outputs.pr_number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TITLE: "自動PR: dev から stagin へ更新"
PR_TITLE: "自動PR: dev から staging へ更新"
2 changes: 2 additions & 0 deletions .github/workflows/deployment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ name: Deployment to dev

on:
pull_request:
types: [closed]
branches:
- dev

jobs:
deployment:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down