Skip to content

Commit

Permalink
Allow to generate badges with build results
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechMazur committed Oct 24, 2023
1 parent 179c827 commit 49911b3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
32 changes: 31 additions & 1 deletion .github/actions/build-project/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ inputs:
workflow-name:
description: "Name of the calling workflow, used to resolve build URL. Leave empty to use default (execute-build-plan / {{github.job}} (<project-name>))"
default: ""
generate-badge:
description: "Should the custom Github badge with the result of build be generated"
default: false

runs:
using: "composite"
steps:
Expand Down Expand Up @@ -142,7 +146,14 @@ runs:
id: check-status
shell: bash
if: steps.check-history.outputs.can-skip-build != 'true'
run: echo "status=$(cat build-status.txt)" >> $GITHUB_OUTPUT
run: |
status=$(cat build-status.txt)
echo "status=${status}" >> $GITHUB_OUTPUT
if [[ "$status" == "success" ]]; then
echo "badgeColor=4CBB17" >> $GITHUB_OUTPUT
else
echo "badgeColor=ED2939" >> $GITHUB_OUTPUT
fi
- name: Get current job URL
id: job-info
Expand Down Expand Up @@ -216,6 +227,25 @@ runs:
echo "::warning title=Indexing failure::Indexing results of ${{ inputs.project-name }} failed"
fi
- uses: tibdex/github-app-token@v1
id: generate-token
if: steps.check-history.outputs.can-skip-build != 'true' && inputs.generate-badge == 'true'
with:
app_id: 303718
private_key: ${{ secrets.OPENCB_CONFIG_UPDATE_TOKEN }}

- name: Generate badge
shell: bash
if: steps.check-history.outputs.can-skip-build != 'true' && inputs.generate-badge == 'true'
uses: RubbaBoy/[email protected]
with:
name: ${{ inputs.project-name }}
label: 'Open Community Build status:'
icon: https://raw.githubusercontent.com/lampepfl/dotty/main/docs/_assets/images/logo.svg
status: ${{ inputs.scala-version }}
color: ${{ steps.check-status.outputs.badgeColor }}
github_token: ${{ steps.generate-token.outputs.token }}

- name: Check results
shell: bash
if: steps.check-history.outputs.can-skip-build != 'true'
Expand Down
3 changes: 3 additions & 0 deletions coordinator/src/main/scala/buildPlan.scala
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ def createGithubActionJob(
| required: true
| OPENCB_ELASTIC_PSWD:
| required: true
| OPENCB_CONFIG_UPDATE_TOKEN:
| required: true
|
|jobs:
| $setupId:
Expand Down Expand Up @@ -505,6 +507,7 @@ def createGithubActionJob(
println(s" maven-repo-url: $${{ $setupOutputs.maven-repo-url }}")
println(" elastic-user: ${{ secrets.OPENCB_ELASTIC_USER }}")
println(" elastic-password: ${{ secrets.OPENCB_ELASTIC_PSWD }}")
println(" generate-badge: true")
}
}
}
Expand Down

0 comments on commit 49911b3

Please sign in to comment.