Skip to content

Merge 6.x into 7.x #131

Merge 6.x into 7.x

Merge 6.x into 7.x #131

Workflow file for this run

name: Merge 6.x into 7.x
on:
workflow_dispatch: {}
schedule:
- cron: '0 23 * * 0' # Run every Sunday at 11 PM UTC (Monday 9 AM AEST)
permissions:
contents: write
pull-requests: write
issues: write
jobs:
create-pull-request:
runs-on: ubuntu-latest
container: ghcr.io/dpc-sdp/bay/ci-builder:6.x
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
ref: 6.x
- name: Set ownership of the workspace
run: chown -R $(id -u):$(id -g) $PWD
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Create PR
id: create-pr
run: |
set +e
output=$(gh pr create --base 7.x --title "Automated PR - merge 6.x into 7.x" --body "This pull request syncs relevant changes from the 6.x branch into the 7.x branch. This PR was automatically generated by the CI workflow." --label "sync" --label "automated" 2>&1)
COMMAND_STATUS=$?
diff=$(echo $output | grep -q "No commits" && echo "false" || echo "true")
echo "stdout<<EOF" | tee "$GITHUB_OUTPUT"
echo $output | tee -a "$GITHUB_OUTPUT"
( echo ; echo "EOF" ) | tee -a "$GITHUB_OUTPUT"
if [[ $diff == "false" ]]; then
echo "There are no commits between the base and HEAD branches." >> $GITHUB_STEP_SUMMARY
COMMAND_STATUS=0
fi
echo "diff=$diff" >> "$GITHUB_OUTPUT"
exit $COMMAND_STATUS
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: If successful set PR number to env var
if: steps.create-pr.conclusion == 'success' && steps.create-pr.outputs.diff == 'true'
run: |
output="${{ steps.create-pr.outputs.stdout }}"
pr_url=$(echo $output | grep -o "^https.*[0-9]")
pr=$(echo $pr_url | cut -d "/" -f 7)
echo "PR_URL=$pr_url" >> GITHUB_ENV
echo "PR_NUMBER=$pr" >> $GITHUB_ENV
- name: Successful, check for conflicts
if: env.PR_NUMBER
run: |
conflicts=$(gh pr view ${{ env.PR_NUMBER }} --json mergeStateStatus --jq 'if .mergeStateStatus == "DIRTY" then true else false end')
echo "CONFLICTS=$conflicts" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Send Slack notification if pr created but conflicts exist
id: notify_slack_conflicts
uses: slackapi/[email protected]
if: always() && env.CONFLICTS
env:
LINK: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
text: "GitHub Action - ${{ github.workflow }} requires manual intervention. \n${{ env.LINK }}"
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "${{ github.workflow }} needs conflicts resolved.\n${{ env.PR_URL }}"
- name: Send Slack notification if PR creation failed for a reason other than "no commits"
id: notify_slack_failed
uses: slackapi/[email protected]
if: always() && (steps.create-pr.conclusion == 'failure' && steps.create-pr.outputs.diff == 'true')
env:
LINK: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: "GitHub Action ${{ github.workflow }} failed. \n${{ env.LINK }}"