|
| 1 | +name: Job messages ⚙️ |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + branch: |
| 7 | + required: false |
| 8 | + type: string |
| 9 | + commit: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + preview_url: |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + build_workflow_run_id: |
| 16 | + required: false |
| 17 | + type: number |
| 18 | + commenting_workflow_run_id: |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + in_progress: |
| 22 | + required: true |
| 23 | + type: boolean |
| 24 | + outputs: |
| 25 | + msg: |
| 26 | + description: The composed message |
| 27 | + value: ${{ jobs.msg.outputs.msg }} |
| 28 | + marker: |
| 29 | + description: Hidden marker to detect PR comments composed by the bot |
| 30 | + value: 'test-deployment' |
| 31 | + |
| 32 | +jobs: |
| 33 | + msg: |
| 34 | + name: Deployment status |
| 35 | + runs-on: ubuntu-latest |
| 36 | + outputs: |
| 37 | + msg: ${{ env.msg }} |
| 38 | + |
| 39 | + steps: |
| 40 | + - name: Compose message 📃 |
| 41 | + if: ${{ always() }} |
| 42 | + id: compose |
| 43 | + env: |
| 44 | + COMMIT: ${{ inputs.commit }} |
| 45 | + DEPLOYMENT_TYPE: ${{ inputs.branch != 'master' && '🔀 Preview' || '⚙️ Production' }} |
| 46 | + BUILD_WORKFLOW_RUN: ${{ !inputs.in_progress && format('**[View build logs](https://github.com/{0}/actions/runs/{1})**', 'gibahjoe/openapi-generator-dart', inputs.build_workflow_run_id) || '' }} |
| 47 | + COMMENTING_WORKFLOW_RUN: ${{ format('**[View bot logs](https://github.com/{0}/actions/runs/{1})**', 'gibahjoe/openapi-generator-dart', inputs.commenting_workflow_run_id) }} |
| 48 | + # EOF is needed for multiline environment variables in a GitHub Actions context |
| 49 | + run: | |
| 50 | + echo "## Cloudflare Pages deployment" > $GITHUB_STEP_SUMMARY |
| 51 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 52 | + echo "| **Latest commit** | <code>${COMMIT::7}</code> |" >> $GITHUB_STEP_SUMMARY |
| 53 | + echo "|------------------------- |:----------------------------: |" >> $GITHUB_STEP_SUMMARY |
| 54 | + echo "| **Status** | $DEPLOY_STATUS |" >> $GITHUB_STEP_SUMMARY |
| 55 | + echo "| **Type** | $DEPLOYMENT_TYPE |" >> $GITHUB_STEP_SUMMARY |
| 56 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 57 | + echo "$BUILD_WORKFLOW_RUN" >> $GITHUB_STEP_SUMMARY |
| 58 | + echo "$COMMENTING_WORKFLOW_RUN" >> $GITHUB_STEP_SUMMARY |
| 59 | + COMPOSED_MSG=$(cat $GITHUB_STEP_SUMMARY) |
| 60 | + echo "msg<<EOF" >> $GITHUB_ENV |
| 61 | + echo "$COMPOSED_MSG" >> $GITHUB_ENV |
| 62 | + echo "EOF" >> $GITHUB_ENV |
0 commit comments