|
| 1 | +--- |
| 2 | +name: Pre-Build Actions (Local) |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + repository: |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + ref: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + fetch-depth: |
| 14 | + required: false |
| 15 | + default: 0 |
| 16 | + type: string |
| 17 | + check-runs: |
| 18 | + type: string |
| 19 | + required: false |
| 20 | + default: "[]" |
| 21 | + notify: |
| 22 | + type: boolean |
| 23 | + default: false |
| 24 | + outputs: |
| 25 | + git_sha_long: |
| 26 | + description: "git sha (long)" |
| 27 | + value: ${{ jobs.export-metadata.outputs.git_sha_long }} |
| 28 | + git_sha_short: |
| 29 | + description: "git sha (short)" |
| 30 | + value: ${{ jobs.export-metadata.outputs.git_sha_short }} |
| 31 | + git_commit_msg: |
| 32 | + description: "git commit message" |
| 33 | + value: ${{ jobs.export-metadata.outputs.git_commit_msg }} |
| 34 | + |
| 35 | +jobs: |
| 36 | + set-vars: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + outputs: |
| 39 | + check-runs-matrix: ${{ steps.set-check-runs-matrix.outputs.check-runs-matrix }} |
| 40 | + steps: |
| 41 | + - name: Set check-runs matrix |
| 42 | + id: set-check-runs-matrix |
| 43 | + run: | |
| 44 | + echo "check-runs-matrix=$input" >> $GITHUB_OUTPUT |
| 45 | + env: |
| 46 | + input: ${{ inputs.check-runs }} |
| 47 | + |
| 48 | + export-github-context: |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - name: Dump GitHub context |
| 52 | + env: |
| 53 | + GITHUB_CONTEXT: ${{ toJson(github) }} |
| 54 | + run: | |
| 55 | + echo "$GITHUB_CONTEXT" |
| 56 | +
|
| 57 | + export-metadata: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + outputs: |
| 60 | + git_sha_long: ${{ steps.export.outputs.git_sha_long }} |
| 61 | + git_sha_short: ${{ steps.export.outputs.git_sha_short }} |
| 62 | + git_commit_msg: ${{ steps.export.outputs.git_commit_msg }} |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@master |
| 65 | + with: |
| 66 | + repository: ${{ inputs.repository }} |
| 67 | + fetch-depth: ${{ inputs.fetch-depth }} |
| 68 | + ref: ${{ inputs.ref }} |
| 69 | + - name: Get metadata from HEAD |
| 70 | + id: export |
| 71 | + run: | |
| 72 | + echo "git_sha_long=${{ inputs.ref }}" >> $GITHUB_OUTPUT |
| 73 | + echo "git_sha_short=$(echo ${{ inputs.ref }} | cut -c1-6)" >> $GITHUB_OUTPUT |
| 74 | + echo "git_commit_msg=$(git log --format=%s -n 1 ${{ inputs.ref }})" >> $GITHUB_OUTPUT |
| 75 | +
|
| 76 | + notify-build-start: |
| 77 | + if: startsWith(github.event.pull_request.head.repo.full_name, github.repository_owner) && inputs.notify |
| 78 | + runs-on: ubuntu-latest |
| 79 | + needs: [export-github-context, export-metadata] |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@master |
| 82 | + with: |
| 83 | + repository: daeuniverse/ci-seed-jobs |
| 84 | + ref: master |
| 85 | + - id: send-notification |
| 86 | + uses: ./notification/notify-build-start |
| 87 | + with: |
| 88 | + telegram_to: ${{ secrets.TELEGRAM_TO }} |
| 89 | + telegram_token: ${{ secrets.TELEGRAM_TOKEN }} |
| 90 | + git_sha_long: ${{ needs.export-metadata.outputs.git_sha_long }} |
| 91 | + git_sha_short: ${{ needs.export-metadata.outputs.git_sha_short }} |
| 92 | + git_commit_msg: ${{ needs.export-metadata.outputs.git_commit_msg }} |
| 93 | + |
| 94 | + instantiate-check-runs: |
| 95 | + needs: [set-vars] |
| 96 | + if: startsWith(github.event.pull_request.head.repo.full_name, github.repository_owner) |
| 97 | + runs-on: ubuntu-latest |
| 98 | + strategy: |
| 99 | + fail-fast: false |
| 100 | + matrix: |
| 101 | + id: ${{ fromJson(needs.set-vars.outputs.check-runs-matrix) }} |
| 102 | + steps: |
| 103 | + - name: Instantiate required check runs |
| 104 | + if: ${{ inputs.check-runs != '[]' }} |
| 105 | + uses: daeuniverse/ci-seed-jobs/common/instantiate-check-runs@master |
| 106 | + with: |
| 107 | + app_id: ${{ secrets.GH_APP_ID }} |
| 108 | + private_key: ${{ secrets.GH_APP_PRIVATE_KEY }} |
| 109 | + id: "dae-bot[bot]/${{ matrix.id }}" |
0 commit comments