CI: test build #78
This file contains hidden or 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: Test Formalities | |
| on: | |
| pull_request_target: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| formalities: | |
| name: Test Formalities | |
| uses: openwrt/actions-shared-workflows/.github/workflows/formal.yml@main | |
| with: | |
| post_comment: true | |
| check_formality_status: | |
| name: Check Formality Status | |
| runs-on: ubuntu-slim | |
| needs: formalities | |
| if: always() | |
| steps: | |
| - name: Trigger build | |
| if: needs.formalities.result == 'success' | |
| env: | |
| # Token needs actions: write | |
| TOKEN: ${{ secrets.DEFAULT_TOKEN }} | |
| API_URL: https://api.github.com/repos/${{ github.repository }}/actions/workflows/multi-arch-test-build.yml/dispatches | |
| BASE_REF: ${{ github.base_ref }} | |
| # Workflow is running in target context, so we need to get head ref | |
| # from the event | |
| HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| PR_NAME: ${{ github.event.pull_request.title }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| JSON_PAYLOAD=$(jq -n \ | |
| --arg head_ref "$HEAD_REF" \ | |
| --arg base_ref "$BASE_REF" \ | |
| --arg pr_number "$PR_NUMBER" \ | |
| --arg pr_name "$PR_NAME" \ | |
| '{ref: $head_ref, inputs: {base_ref: $base_ref, pr_number: $pr_number, pr_name: $pr_name}}') | |
| curl -L \ | |
| -X POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $TOKEN" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "$API_URL" \ | |
| -d "$JSON_PAYLOAD" | |
| - name: Trigger check | |
| if: needs.formalities.result == 'failure' | |
| env: | |
| # Token needs actions: write | |
| TOKEN: ${{ secrets.DEFAULT_TOKEN }} | |
| API_URL: https://api.github.com/repos/${{ github.repository }}/actions/workflows/check.yml/dispatches | |
| BASE_REF: ${{ github.base_ref }} | |
| # Workflow is running in target context, so we need to get head ref | |
| # from the event | |
| HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| PR_NAME: ${{ github.event.pull_request.title }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| JSON_PAYLOAD=$(jq -n \ | |
| --arg head_ref "$HEAD_REF" \ | |
| --arg base_ref "$BASE_REF" \ | |
| --arg pr_number "$PR_NUMBER" \ | |
| --arg pr_name "$PR_NAME" \ | |
| '{ref: $head_ref, inputs: {base_ref: $base_ref, pr_number: $pr_number, pr_name: $pr_name}}') | |
| curl -L \ | |
| -X POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $TOKEN" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "$API_URL" \ | |
| -d "$JSON_PAYLOAD" | |
| - name: Add 'not following guidelines' label | |
| if: needs.formalities.result == 'failure' | |
| uses: buildsville/[email protected] | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| labels: "not following guidelines" | |
| type: add | |
| - name: Remove 'not following guidelines' label | |
| if: needs.formalities.result == 'success' | |
| uses: buildsville/[email protected] | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| labels: "not following guidelines" | |
| type: remove |