mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-17 01:53:35 +01:00
Follow-up patch for "tidies other workflows and adds better logging" (#24864)
* null check is important in other languages too * null check is important in other languages too * 1/0 * simplify this * readd user info * remove this to test * new name
This commit is contained in:
@@ -22,6 +22,7 @@ jobs:
|
||||
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||
|
||||
- run: echo "GH_TOKEN=${{ steps.create_token.outputs.token }}" >> "$GITHUB_ENV"
|
||||
- run: echo "FAIL_NOTIFIED=false" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Like the comment
|
||||
run: |
|
||||
@@ -37,7 +38,8 @@ jobs:
|
||||
pr_json=$(curl -L -s --fail-with-body -H "Authorization: token ${{ github.token }}" ${{ github.event.issue.pull_request.url }})
|
||||
if [ `jq -r '.maintainer_can_modify' <<<$pr_json` == "false" ] ; then
|
||||
gh pr comment ${{ github.event.issue.html_url }} --body 'GitHub Actions can not push to the repository without "Allow edits and access to secrets by maintainers" checked.'
|
||||
exit 0
|
||||
echo "FAIL_NOTIFIED=true" >> "$GITHUB_ENV"
|
||||
exit 1
|
||||
fi
|
||||
echo "PR_REPO=`jq -r '.head.repo.full_name' <<<$pr_json`" >> $GITHUB_ENV
|
||||
echo "PR_BRANCH=`jq -r '.head.ref' <<<$pr_json`" >> $GITHUB_ENV
|
||||
@@ -89,6 +91,8 @@ jobs:
|
||||
chmod +x tools/hooks/*.merge tgui/bin/tgui
|
||||
|
||||
# Actual Merge
|
||||
git config user.name paradisess13[bot]
|
||||
git config user.email "165046124+paradisess13[bot]@users.noreply.github.com"
|
||||
git remote add upstream "https://github.com/$BASE_REPOSITORY.git"
|
||||
|
||||
git fetch origin "$PR_BRANCH" --depth=$((ahead_by + 1))
|
||||
@@ -97,33 +101,15 @@ jobs:
|
||||
# Check if a workflow file would be modified by the merge (permissions prevent pushes if so)
|
||||
latest_workflow_commit=$(git log -n 1 --pretty=format:"%H" upstream/$BASE_BRANCH -- .github/workflows)
|
||||
if ! git branch --contains $latest_workflow_commit | grep -q "$(git rev-parse --abbrev-ref HEAD)"; then
|
||||
gh pr comment ${{ github.event.issue.html_url }} --body "GitHub Actions can not push to this branch as workflow files have been changed since your branch was last updated. Please update your branch past https://github.com/ParadiseSS13/Paradise/commit/$latest_workflow_commit before using this command again."
|
||||
exit 0
|
||||
gh pr comment ${{ github.event.issue.html_url }} --body "GitHub Actions can not push to this branch as workflow files have been changed since your branch was last updated. Please update your branch past https://github.com/ParadiseSS13/Paradise/commit/$latest_workflow_commit before using this command again."#
|
||||
echo "FAIL_NOTIFIED=true" >> "$GITHUB_ENV"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git merge FETCH_HEAD
|
||||
git push origin
|
||||
|
||||
- name: Approve Workflows
|
||||
run: |
|
||||
# Get the list of pending workflow runs for paradisess13bot
|
||||
runs=$(gh api \
|
||||
--method POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
/repos/ParadiseSS13/Paradise/actions/runs?actor=paradisess13bot&status=action_required)
|
||||
run_ids=$(echo $runs | jq -r '.workflow_runs[].id')
|
||||
|
||||
# Iterate over the run IDs, approving each one
|
||||
for run_id in $run_ids; do
|
||||
gh api \
|
||||
--method POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
/repos/ParadiseSS13/Paradise/actions/runs/$run_id/approve
|
||||
done
|
||||
|
||||
- name: Notify Failure
|
||||
if: failure()
|
||||
if: failure() && env.FAIL_NOTIFIED != 'true'
|
||||
run: |
|
||||
gh pr comment ${{ github.event.issue.html_url }} -b 'Merging upstream failed, see the action run log for details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
|
||||
|
||||
Reference in New Issue
Block a user