mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-09 23:48:01 -05:00
Add draft flag to PR generation and build worflows. (#12250)
Signed-off-by: Satadru Pramanik <satadru@gmail.com> Co-authored-by: Satadru Pramanik <satadru@gmail.com>
This commit is contained in:
committed by
GitHub
parent
9df24c24a7
commit
e790554968
24
.github/workflows/Build.yml
vendored
24
.github/workflows/Build.yml
vendored
@@ -6,8 +6,12 @@ on:
|
||||
with_pr:
|
||||
description: "Create a PR after building."
|
||||
required: false
|
||||
type: boolean
|
||||
default: 'true'
|
||||
type: choice
|
||||
default: 'Pull Request'
|
||||
options:
|
||||
- Pull Request
|
||||
- Draft Pull Request
|
||||
- No
|
||||
allow_fail:
|
||||
description: "Allow packages to fail building."
|
||||
required: false
|
||||
@@ -479,13 +483,14 @@ jobs:
|
||||
organization: chromebrew
|
||||
revoke_token: true
|
||||
- name: Create Pull Request
|
||||
if: ${{ github.event.inputs.with_pr == 'true' }}
|
||||
if: ${{ github.event.inputs.with_pr != 'No' }}
|
||||
env:
|
||||
CHANGED_GITHUB_CONFIG_FILES: ${{ steps.changed-files.outputs.github_all_changed_files }}
|
||||
CHANGED_MANIFEST_FILES: ${{ steps.changed-files.outputs.manifest_all_changed_files }}
|
||||
CHANGED_OTHER_FILES: ${{ steps.changed-files.outputs.other_all_changed_files }}
|
||||
CHANGED_PACKAGES: ${{ needs.setup.outputs.changed_packages }}
|
||||
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
|
||||
PR_TYPE: ${{ github.event.inputs.with_pr }}
|
||||
TIMESTAMP: ${{ needs.setup.outputs.timestamp }}
|
||||
i686_PACKAGES: ${{ needs.setup.outputs.i686_packages }}
|
||||
x86_64_PACKAGES: ${{ needs.setup.outputs.x86_64_packages }}
|
||||
@@ -526,8 +531,17 @@ jobs:
|
||||
echo -e "CREW_REPO=https://github.com/chromebrew/chromebrew.git CREW_BRANCH=${{ env.BRANCH }} crew update \\" >> /tmp/pr.txt
|
||||
echo -e "&& yes | crew upgrade\n\`\`\`" >> /tmp/pr.txt
|
||||
cat /tmp/pr.txt
|
||||
PR_NUMBER=$(gh pr create --reviewer chromebrew/active --title "Build: ${{ env.BRANCH }} started at ${TIMESTAMP}." -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
|
||||
[[ $PR_TYPE == 'Draft Pull Request' ]] && export PR_DRAFT_FLAG='-d'
|
||||
if [[ -z ${PR_NUMBER} ]]; then
|
||||
PR_NUMBER=$(gh pr create ${PR_DRAFT_FLAG} --reviewer chromebrew/active --title "Build: ${{ env.BRANCH }} started at ${TIMESTAMP}." -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
|
||||
else
|
||||
gh pr edit -F /tmp/pr.txt
|
||||
fi
|
||||
# Draft PRs can not be set to automerge.
|
||||
gh pr merge "${PR_NUMBER}" --auto || true
|
||||
if [[ PR_TYPE == 'Draft Pull Request' ]]; then
|
||||
gh pr ready --undo || true
|
||||
else
|
||||
gh pr merge --auto || true
|
||||
fi
|
||||
echo "PR_NUMBER is ${PR_NUMBER}"
|
||||
echo "PR_NUMBER=${PR_NUMBER}" >> "$GITHUB_ENV"
|
||||
|
||||
15
.github/workflows/Generate-PR.yml
vendored
15
.github/workflows/Generate-PR.yml
vendored
@@ -3,6 +3,11 @@ name: Generate PR
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
draft_pr:
|
||||
description: "Create a Draft PR."
|
||||
required: false
|
||||
type: boolean
|
||||
default: 'false'
|
||||
branch:
|
||||
description: "Branch of chromebrew/chromebrew to run on, if different from this branch."
|
||||
required: false
|
||||
@@ -183,6 +188,7 @@ jobs:
|
||||
CHANGED_OTHER_FILES: ${{ steps.changed-files.outputs.other_all_changed_files }}
|
||||
CHANGED_PACKAGES: ${{ needs.setup.outputs.changed_packages }}
|
||||
CREW_BRANCH: ${{ inputs.branch || github.ref_name }}
|
||||
DRAFT_PR: ${{ github.event.inputs.draft_pr }}
|
||||
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
|
||||
TIMESTAMP: ${{ needs.setup.outputs.timestamp }}
|
||||
i686_PACKAGES: ${{ needs.setup.outputs.i686_packages }}
|
||||
@@ -223,13 +229,18 @@ jobs:
|
||||
echo -e "CREW_REPO=https://github.com/chromebrew/chromebrew.git CREW_BRANCH=${{ env.BRANCH }} crew update \\" >> /tmp/pr.txt
|
||||
echo -e "&& yes | crew upgrade\n\`\`\`" >> /tmp/pr.txt
|
||||
cat /tmp/pr.txt
|
||||
[[ $DRAFT_PR == 'true' ]] && export PR_DRAFT_FLAG='-d'
|
||||
PR_NUMBER=$(gh pr list -H ${CREW_BRANCH}| cut -f1)
|
||||
if [[ -z ${PR_NUMBER} ]]; then
|
||||
PR_NUMBER=$(gh pr create --reviewer chromebrew/active --title "${{ env.BRANCH }} at ${TIMESTAMP}." -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
|
||||
PR_NUMBER=$(gh pr create ${PR_DRAFT_FLAG} --reviewer chromebrew/active --title "${{ env.BRANCH }} at ${TIMESTAMP}." -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
|
||||
else
|
||||
gh pr edit -F /tmp/pr.txt
|
||||
fi
|
||||
# Draft PRs can not be set to automerge.
|
||||
gh pr merge "${PR_NUMBER}" --auto || true
|
||||
if [[ $DRAFT_PR == 'true' ]]; then
|
||||
gh pr ready --undo || true
|
||||
else
|
||||
gh pr merge --auto || true
|
||||
fi
|
||||
echo "PR_NUMBER is ${PR_NUMBER}"
|
||||
echo "PR_NUMBER=${PR_NUMBER}" >> "$GITHUB_ENV"
|
||||
|
||||
19
.github/workflows/No-Compile-Needed.yml
vendored
19
.github/workflows/No-Compile-Needed.yml
vendored
@@ -3,6 +3,11 @@ name: No-Compile-Needed
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
draft_pr:
|
||||
description: "Create a Draft PR."
|
||||
required: false
|
||||
type: boolean
|
||||
default: 'false'
|
||||
branch:
|
||||
description: "Branch of chromebrew/chromebrew to run on, if different from this branch."
|
||||
required: false
|
||||
@@ -357,6 +362,7 @@ jobs:
|
||||
CHANGED_MANIFEST_FILES: ${{ steps.changed-files.outputs.manifest_all_changed_files }}
|
||||
CHANGED_OTHER_FILES: ${{ steps.changed-files.outputs.other_all_changed_files }}
|
||||
CHANGED_PACKAGES: ${{ needs.setup.outputs.changed_packages }}
|
||||
DRAFT_PR: ${{ github.event.inputs.draft_pr }}
|
||||
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
|
||||
TIMESTAMP: ${{ needs.setup.outputs.timestamp }}
|
||||
i686_PACKAGES: ${{ needs.setup.outputs.i686_packages }}
|
||||
@@ -398,8 +404,17 @@ jobs:
|
||||
echo -e "CREW_REPO=https://github.com/chromebrew/chromebrew.git CREW_BRANCH=${{ env.BRANCH }} crew update \\" >> /tmp/pr.txt
|
||||
echo -e "&& yes | crew upgrade\n\`\`\`" >> /tmp/pr.txt
|
||||
cat /tmp/pr.txt
|
||||
PR_NUMBER=$(gh pr create --reviewer chromebrew/active --title "Build: ${{ env.BRANCH }} started at ${TIMESTAMP}." -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
|
||||
[[ $DRAFT_PR == 'true' ]] && export PR_DRAFT_FLAG='-d'
|
||||
if [[ -z ${PR_NUMBER} ]]; then
|
||||
PR_NUMBER=$(gh pr create ${PR_DRAFT_FLAG} --reviewer chromebrew/active --title "Build: ${{ env.BRANCH }} started at ${TIMESTAMP}." -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
|
||||
else
|
||||
gh pr edit -F /tmp/pr.txt
|
||||
fi
|
||||
# Draft PRs can not be set to automerge.
|
||||
gh pr merge "${PR_NUMBER}" --auto || true
|
||||
if [[ $DRAFT_PR == 'true' ]]; then
|
||||
gh pr ready --undo || true
|
||||
else
|
||||
gh pr merge --auto || true
|
||||
fi
|
||||
echo "PR_NUMBER is ${PR_NUMBER}"
|
||||
echo "PR_NUMBER=${PR_NUMBER}" >> "$GITHUB_ENV"
|
||||
|
||||
Reference in New Issue
Block a user