-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Allow format fix on PRs from forks (#37393)
- Loading branch information
1 parent
8aa506c
commit 1c187e9
Showing
3 changed files
with
116 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
name: Fix formatting on a PR | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
pr: | ||
description: "Pull request number. Used to pull the proper branch ref, including on forks." | ||
required: false | ||
comment-id: | ||
description: "Optional. The comment-id of the slash command. Used to update the comment with the status." | ||
required: false | ||
|
||
run-name: "Fix formatting on PR #${{ github.event.inputs.pr }}" | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.inputs.pr }} | ||
# Cancel any previous runs on the same branch if they are still in progress | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
format-fix: | ||
name: "Run airbyte-ci format fix all" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Airbyte | ||
uses: actions/checkout@v3 | ||
with: | ||
# Important that this is set so that CI checks are triggered again | ||
# Without this we would be forever waiting on required checks to pass | ||
token: ${{ secrets.GH_PAT_APPROVINGTON_OCTAVIA }} | ||
fetch-depth: 1 | ||
|
||
- name: Checkout PR (${{ github.event.inputs.pr }}) | ||
uses: dawidd6/action-checkout-pr@v1 | ||
with: | ||
pr: ${{ github.event.inputs.pr }} | ||
|
||
- name: Get job variables | ||
id: job-vars | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
shell: bash | ||
run: | | ||
PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.inputs.pr }}) | ||
echo "::set-output name=repo::$(echo "$PR_JSON" | jq -r .head.repo.full_name)" | ||
echo "::set-output name=branch::$(echo "$PR_JSON" | jq -r .head.ref)" | ||
echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT | ||
- name: Append comment with job run link | ||
# If not comment-id is provided, this will create a new | ||
# comment with the job run link. | ||
id: first-comment-action | ||
uses: peter-evans/create-or-update-comment@v4 | ||
with: | ||
comment-id: ${{ github.event.inputs.comment-id }} | ||
issue-number: ${{ github.event.inputs.pr }} | ||
body: | | ||
> Format-fix job started... [Check job output.][1] | ||
[1]: ${{ steps.job-vars.outputs.run-url }} | ||
- name: Run airbyte-ci format fix all | ||
uses: ./.github/actions/run-airbyte-ci | ||
continue-on-error: true | ||
with: | ||
context: "manual" | ||
dagger_cloud_token: ${{ secrets.DAGGER_CLOUD_TOKEN_2 }} | ||
docker_hub_password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
docker_hub_username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
gcs_credentials: ${{ secrets.METADATA_SERVICE_PROD_GCS_CREDENTIALS }} | ||
sentry_dsn: ${{ secrets.SENTRY_AIRBYTE_CI_DSN }} | ||
github_token: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }} | ||
subcommand: "format fix all" | ||
|
||
# This is helpful in the case that we change a previously committed generated file to be ignored by git. | ||
- name: Remove any files that have been gitignored | ||
run: git ls-files -i -c --exclude-from=.gitignore | xargs -r git rm --cached | ||
|
||
- name: Commit Formatting Changes (PR) | ||
id: commit-step | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
# Don't commit if we're on master | ||
if: github.ref != 'refs/heads/master' | ||
with: | ||
commit_message: "chore: format code" | ||
commit_user_name: Octavia Squidington III | ||
commit_user_email: octavia-squidington-iii@users.noreply.github.com | ||
|
||
- name: Append success comment | ||
uses: peter-evans/create-or-update-comment@v4 | ||
if: steps.commit-step.outputs.changes_detected == 'true' | ||
with: | ||
comment-id: ${{ steps.first-comment-action.outputs.comment-id }} | ||
reactions: hooray | ||
body: | | ||
> ✅ Changes applied successfully. (${{ steps.commit-step.outputs.commit_hash }}) | ||
- name: Append success comment (no-op) | ||
uses: peter-evans/create-or-update-comment@v4 | ||
if: steps.commit-step.outputs.changes_detected != 'true' | ||
with: | ||
comment-id: ${{ steps.first-comment-action.outputs.comment-id }} | ||
reactions: "+1" | ||
body: | | ||
> 🟦 Job completed successfully (no changes). | ||
- name: Append failure comment | ||
uses: peter-evans/create-or-update-comment@v4 | ||
if: failure() | ||
with: | ||
comment-id: ${{ steps.first-comment-action.outputs.comment-id }} | ||
reactions: confused | ||
body: | | ||
> ❌ Job failed. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters