|
| 1 | +name: JUCE Private Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + triggerer: |
| 7 | + required: false |
| 8 | + type: string |
| 9 | + default: '' |
| 10 | + description: The GitHub ID to receive email notifications (leave blank) |
| 11 | + nightly-targets: |
| 12 | + required: false |
| 13 | + type: string |
| 14 | + default: "[]" |
| 15 | + description: A list of nightly build targets in JSON format |
| 16 | + cpp-std: |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + default: "" |
| 20 | + description: The C++ standard to use (optional [20, 23]) |
| 21 | + |
| 22 | +env: |
| 23 | + target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 24 | + |
| 25 | +run-name: "[${{ inputs.triggerer && inputs.triggerer || github.event.sender.login }}] ${{ github.sha }}" |
| 26 | + |
| 27 | +jobs: |
| 28 | + setup: |
| 29 | + if: ${{ (inputs.nightly-targets == '[]') && (inputs.cpp-std == '') }} |
| 30 | + name: Check and set CI commit status |
| 31 | + runs-on: ubuntu-latest |
| 32 | + env: |
| 33 | + GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + outputs: |
| 35 | + build: ${{ steps.status_check.outputs.build }} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4.2.2 |
| 38 | + with: |
| 39 | + fetch-depth: 0 |
| 40 | + sparse-checkout: | |
| 41 | + .github/workflows |
| 42 | + - id: status_check |
| 43 | + shell: python |
| 44 | + run: | |
| 45 | + import sys |
| 46 | + import os |
| 47 | + sys.path.append(os.path.abspath('.github/workflows')) |
| 48 | + from github_api_request import json_github_api_request |
| 49 | + sha = os.environ["GITHUB_SHA"] |
| 50 | + statuses_response = json_github_api_request(f'commits/{sha}/statuses') |
| 51 | + status = next(filter(lambda x: x['context'] == 'CI', statuses_response), None) |
| 52 | + if (status is None) or (status['state'] != 'success'): |
| 53 | + with open(os.environ['GITHUB_OUTPUT'], 'a') as f: |
| 54 | + f.write(f'build=1\n') |
| 55 | + data = { |
| 56 | + 'state': 'pending', |
| 57 | + 'context': 'CI', |
| 58 | + 'target_url': os.environ['target_url'], |
| 59 | + } |
| 60 | + post_response = json_github_api_request(f'statuses/{sha}', 'POST', data) |
| 61 | + print(post_response) |
| 62 | + build: |
| 63 | + if: ${{ !cancelled() && (success() || needs.setup.result == 'skipped') && (inputs.nightly-targets != '[]' || inputs.cpp-std != '' || needs.setup.outputs.build == '1' || contains(fromJSON('["master"]'), github.ref_name)) }} |
| 64 | + needs: [setup] |
| 65 | + name: . |
| 66 | + # Not having the ability to do a dynamic 'uses' call is a real pain. To |
| 67 | + # test some new CI configuration you must set the branch in both places |
| 68 | + # below. |
| 69 | + uses: juce-framework/JUCE-utils/.github/workflows/main.yml@master |
| 70 | + with: |
| 71 | + juce-utils-branch: master |
| 72 | + nightly-targets: ${{ inputs.nightly-targets }} |
| 73 | + triggerer: ${{ inputs.triggerer && inputs.triggerer || github.event.sender.login }} |
| 74 | + cpp-std: ${{ inputs.cpp-std }} |
| 75 | + secrets: inherit |
| 76 | + deploy: |
| 77 | + if: ${{ !cancelled() && (success() || needs.build.result == 'skipped') && contains(fromJSON('["master", "develop"]'), github.ref_name) && inputs.cpp-std == '' && inputs.nightly-targets == '[]' }} |
| 78 | + needs: [build] |
| 79 | + name: Deploy |
| 80 | + uses: juce-framework/JUCE-utils/.github/workflows/deploy.yml@master |
| 81 | + secrets: inherit |
| 82 | + docs: |
| 83 | + if: ${{ !cancelled() && (success() || needs.deploy.result == 'success') && contains(fromJSON('["master", "develop"]'), github.ref_name) && inputs.cpp-std == '' && inputs.nightly-targets == '[]' }} |
| 84 | + needs: [deploy] |
| 85 | + name: Docs |
| 86 | + uses: juce-framework/JUCE-utils/.github/workflows/docs.yml@master |
| 87 | + secrets: inherit |
| 88 | + set-commit-status: |
| 89 | + if: ${{ always() && (inputs.nightly-targets == '[]') && (inputs.cpp-std == '') }} |
| 90 | + needs: [setup, build, deploy, docs] |
| 91 | + name: Set CI commit status |
| 92 | + runs-on: ubuntu-latest |
| 93 | + env: |
| 94 | + result: ${{ contains(needs.*.result, 'cancelled') && 'cancelled' || (contains(needs.*.result, 'failure') && 'failure' || 'success') }} |
| 95 | + steps: |
| 96 | + - uses: myrotvorets/set-commit-status-action@master |
| 97 | + with: |
| 98 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + sha: ${{ github.sha }} |
| 100 | + status: ${{ contains(fromJSON('["cancelled", "failure"]'), env.result) && 'failure' || env.result }} |
| 101 | + context: CI |
| 102 | + description: ${{ env.result }} |
| 103 | + targetUrl: ${{ env.target_url }} |
| 104 | + notify: |
| 105 | + if: ${{ always() && !contains(needs.*.result, 'cancelled') }} |
| 106 | + needs: [setup, build, deploy, docs] |
| 107 | + name: Notify |
| 108 | + uses: juce-framework/JUCE-utils/.github/workflows/notify.yml@master |
| 109 | + with: |
| 110 | + juce-utils-branch: master |
| 111 | + triggerer: ${{ inputs.triggerer && inputs.triggerer || github.event.sender.login }} |
| 112 | + context: ${{ toJson(needs) }} |
| 113 | + secrets: inherit |
0 commit comments