docs: test branch #23
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: Merge Queue E2E Status Check | |
on: | |
issue_comment: | |
types: | |
- created | |
- edited | |
- deleted | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- labeled | |
- unlabeled | |
- synchronize | |
jobs: | |
is-fork-pull-request: | |
name: Determine pull request source | |
if: ${{ github.event.issue.pull_request || github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
outputs: | |
IS_FORK: ${{ steps.is-fork.outputs.IS_FORK }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Determine whether this PR is from a fork | |
id: is-fork | |
run: | | |
echo "IS_FORK=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "${PR_NUMBER}" )" >> "$GITHUB_OUTPUT" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_NUMBER: ${{ github.event.number || github.event.issue.number }} | |
is-documentation-pull-request: | |
name: Check if pull request is for documentation | |
runs-on: ubuntu-latest | |
outputs: | |
IS_DOCS_PR: ${{ steps.is-docs.outputs.IS_DOCS_PR }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check if docs PR | |
id: is-docs | |
run: | | |
if [[ "${{ startsWith(github.event.pull_request.title, 'docs:') }}" == "true" ]]; then | |
echo "Is a documentation PR, will skip running e2e" | |
else | |
echo "Is not a documentation PR will proceed to running tests" | |
fi | |
check-if-bitrise-ran: | |
name: Check if E2E comment is success | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install jq | |
run: | | |
sudo apt-get install jq | |
- name: Check if PR has Bitrise status commented | |
id: check_bitrise_comment | |
run: | | |
# Fetch all PR comments | |
PR_COMMENTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/comments") | |
# Extract the latest comment from GitHub Actions bot related to pr_smoke_e2e_pipeline | |
LATEST_BOT_COMMENT=$(echo "$PR_COMMENTS" | jq -r \ | |
'.[] | select(.user.login == "github-actions[bot]" and (.body | test("pr_smoke_e2e_pipeline"))) | .body' | tail -n 1) | |
# Check if the most recent comment indicates pass or fail | |
if [[ "$LATEST_BOT_COMMENT" == *"✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅"* ]]; then | |
echo "Latest E2E comment indicates success." | |
elif [[ "$LATEST_BOT_COMMENT" == *"❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌"* ]]; then | |
echo "Latest E2E comment indicates failure." | |
exit 1 | |
else | |
echo "No relevant Bitrise comment found." | |
exit 1 | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
e2e-all-jobs-pass: | |
name: All jobs pass | |
runs-on: ubuntu-20.04 | |
needs: | |
[ | |
is-fork-pull-request, | |
check-if-bitrise-ran, | |
is-documentation-pull-request | |
] | |
outputs: | |
ALL_JOBS_PASSED: ${{ steps.jobs-passed-status.outputs.ALL_JOBS_PASSED }} | |
steps: | |
- name: Set jobs passed status | |
id: jobs-passed-status | |
run: echo "ALL_JOBS_PASSED=true" >> "$GITHUB_OUTPUT" | |
check-all-jobs-pass: | |
name: Check all jobs pass | |
runs-on: ubuntu-20.04 | |
needs: e2e-all-jobs-pass | |
if: always() | |
steps: | |
- run: | | |
if [[ "${{ needs.all-jobs-pass.outputs.ALL_JOBS_PASSED }}" == "true" ]]; then | |
echo "All jobs passed. Unblock PR." | |
else | |
echo "All jobs passed step skipped. Block PR." | |
exit 1 | |
fi |