CI: run npm run test on pull requests in existing workflow
#1514
Workflow file for this run
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: On Demand Preview Releases for PR | |
| # avoids paths like .md, and anything in .github folder | |
| on: | |
| # This workflow executes PR Code by checkout later | |
| # MUST approve the PR Code BEFORE using this workflow on PRs. | |
| # Uses this trigger to keep up-to-date execution of the workflow (triggers from Default Branch) | |
| pull_request_target: | |
| paths-ignore: | |
| - '!*.md' | |
| # - '.github/**' | |
| types: [labeled, synchronize] | |
| # defined at workflow-level as the workflow, Requires these permissions to function. | |
| permissions: | |
| contents: read | |
| concurrency: | |
| # Allow only one workflow per any non-`main` branch. | |
| group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }} | |
| cancel-in-progress: true | |
| jobs: | |
| job_trigger: | |
| name: Trigger Preview Release (if conditions met) | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| if: >- | |
| github.event.pull_request.draft == false && | |
| github.repository_owner == 'Acode-Foundation' && | |
| (!contains(github.event.pull_request.labels.*.name, 'DO NOT PREVIEW RELEASE') && | |
| (github.event.action == 'labeled' && github.event.label.name == 'CI: RUN ON-DEMAND PREVIEW RELEASES' || | |
| github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'Bypass check - PREVIEW RELEASE')) | |
| ) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| with: | |
| clean: false | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Remove Manually added PR Label | |
| if: | | |
| contains(github.event.pull_request.labels.*.name, 'CI: RUN ON-DEMAND PREVIEW RELEASES') | |
| run: gh pr edit $PR --remove-label "$labels" | |
| env: | |
| PR: ${{ github.event.pull_request.number }} | |
| labels: 'CI: RUN ON-DEMAND PREVIEW RELEASES' | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Add comment to PR | |
| uses: marocchino/sticky-pull-request-comment@v3 | |
| with: | |
| hide_and_recreate: true | |
| hide_classify: "OUTDATED" | |
| header: on-demand-build-status | |
| message: | | |
| ⚒️ Starting a workflow to build, Your On-Demand Preview Release/build for ${{ github.event.pull_request.html_url || github.event.pull_request.url }}. | |
| status: **`🟡 in_progress`** | |
| Kindly wait, this message may be updated with success or failure status. | |
| Please [Click here to view that github actions](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }})/ | |
| env: | |
| PR: ${{ github.event.pull_request.number }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| trigger_builder: | |
| needs: job_trigger | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| issues: read | |
| secrets: | |
| KEYSTORE_CONTENT: ${{ secrets.KEYSTORE_CONTENT }} | |
| BUILD_JSON_CONTENT: ${{ secrets.BUILD_JSON_CONTENT }} | |
| uses: Acode-Foundation/acode/.github/workflows/nightly-build.yml@main | |
| with: | |
| is_PR: true | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| is_trusted_pr: ${{ github.event.pull_request.head.repo.full_name == github.repository }} | |
| update_Last_Comment: | |
| needs: [job_trigger,trigger_builder] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| if: ${{ github.repository_owner == 'Acode-Foundation' && always() && contains(fromJSON('["failure","cancelled", "success"]'), needs.trigger_builder.result) }} | |
| steps: | |
| - name: Update Last Comment by bot (If Workflow Triggering succeeded) | |
| if: ${{ needs.trigger_builder.result == 'success' && github.event.pull_request.number }} | |
| uses: marocchino/sticky-pull-request-comment@v3 | |
| with: | |
| hide_and_recreate: true | |
| hide_classify: "OUTDATED" | |
| header: on-demand-build-status | |
| message: | | |
| Preview Release for this, has been built. | |
| [Click here to view that github actions build](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }}) | |
| - name: Update Last Comment by bot (if Workflow Triggering failed) | |
| if: ${{ needs.trigger_builder.result != 'success' && github.event.pull_request.number }} | |
| uses: marocchino/sticky-pull-request-comment@v3 | |
| with: | |
| hide_and_recreate: true | |
| hide_classify: "OUTDATED" | |
| header: on-demand-build-status | |
| message: | | |
| 🔴 (Workflow Trigger stopped), Your On-Demand Preview Release/build for ${{ github.event.pull_request.html_url || github.event.pull_request.url }}. | |
| status: **${{ needs.trigger_builder.result || 'failure'}}** | |
| --- | |
| Please [Click here to view that github actions](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }}) |