Update 20250214190426 #827
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
name: '[CI/CD] CI Pipeline' | |
on: # rebuild any PRs and main branch changes | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
branches: | |
- main | |
- bitnami:main | |
permissions: {} | |
# Avoid concurrency over the same PR | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
name: Linter | |
permissions: | |
contents: read | |
outputs: | |
allow_auto_merge: ${{ steps.lint.outputs.allow_auto_merge }} | |
steps: | |
- name: Install system deps | |
run: sudo apt-get install -y jq python3 pipx | |
- name: Install markdownlint | |
run: npm install -g [email protected] | |
- name: Install check-jsonschema | |
run: pipx install check-jsonschema | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
name: Checkout Repository | |
- id: lint | |
name: Lint modified files | |
env: | |
# Max number of modified files in PR that are allowed to be automerged | |
LINTED_FILES_THRESHOLD: 20 | |
DIFF_URL: "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | |
run: | | |
# Get the list of files changed in the PR | |
files_changed_data=$(curl -s --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X GET -G "$DIFF_URL") | |
files_changed="$(echo "$files_changed_data" | jq -r .[].filename | paste -s -d ' ')" | |
# Populate extra output. Do not automerge if too many files were updated | |
num_files_changed="$(echo "$files_changed_data" | jq -r 'length')" | |
allow_auto_merge="true" | |
if [[ "$num_files_changed" -gt "$LINTED_FILES_THRESHOLD" ]]; then | |
allow_auto_merge="false" | |
fi | |
echo "allow_auto_merge=${allow_auto_merge}" >> $GITHUB_OUTPUT | |
# Lint changed files only | |
bash "${{ github.workspace }}/scripts/lint.sh" "$files_changed" | |
auto-pr-review: | |
runs-on: ubuntu-latest | |
needs: lint | |
name: Reviewal for automated PRs | |
permissions: | |
pull-requests: write | |
# Only auto-merge if PR was created by bitnami-bot user | |
if: | | |
always() && | |
github.event.pull_request.user.login == 'bitnami-bot' | |
steps: | |
# Approve the CI's PR if the 'lint' job succeeded | |
# Approved by the 'github-actions' user; a PR can't be approved by its author | |
- name: PR approval | |
if: | | |
needs.lint.result == 'success' && | |
needs.lint.outputs.allow_auto_merge == 'true' | |
uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0 | |
with: | |
pull-request-number: ${{ github.event.number }} | |
- name: Merge | |
id: merge | |
if: | | |
needs.lint.result == 'success' && | |
needs.lint.outputs.allow_auto_merge == 'true' | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
with: | |
result-encoding: string | |
retries: 3 | |
github-token: ${{ secrets.BITNAMI_BOT_TOKEN }} | |
script: | | |
github.rest.pulls.merge({ | |
pull_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
merge_method: 'squash' | |
}) | |
# If the CI did not succeed ('lint' failed or skipped), | |
# post a comment on the PR and assign a maintainer agent to review it | |
- name: Manual review required | |
if: ${{ always() && (needs.lint.result != 'success' || steps.merge.outcome != 'success' ) }} | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
with: | |
issue-number: ${{ github.event.number }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: | | |
There has been an error during the automated release process. Manual revision is now required. | |
Please check the related [action_run#${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more information and the changes in the final files (too many files updated at the same time?). | |
- name: Assign to a person to work on it | |
if: ${{ always() && (needs.lint.result != 'success' || steps.merge.outcome != 'success' ) }} | |
uses: pozil/auto-assign-issue@39c06395cbac76e79afc4ad4e5c5c6db6ecfdd2e # v2.2.0 | |
with: | |
numOfAssignee: 1 | |
teams: ${{ secrets.SUPPORT_TEAM }} | |
repo-token: ${{ secrets.BITNAMI_BOT_TOKEN }} | |
allowSelfAssign: false |