|
| 1 | +# See reference docs at |
| 2 | +# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions |
| 3 | +name: Per commit CI |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + sha: |
| 8 | + description: Git commit to check |
| 9 | + required: true |
| 10 | + base_ref: |
| 11 | + description: Base reference we are comparing against (e.g., 'master') |
| 12 | + required: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + ci: |
| 16 | + runs-on: ubuntu-22.04 |
| 17 | + steps: |
| 18 | + - name: Set commit status to pending |
| 19 | + run: | |
| 20 | + curl -L -s \ |
| 21 | + -X POST \ |
| 22 | + -H "Accept: application/vnd.github+json" \ |
| 23 | + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ |
| 24 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 25 | + ${{ github.api_url }}/repos/${{ github.repository }}/statuses/${{ inputs.sha }} \ |
| 26 | + -d '{"state":"pending","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","description":"The build started!","context":"ci / per-commit-build"}' |
| 27 | +
|
| 28 | + - name: Clone the repo |
| 29 | + uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + submodules: recursive |
| 32 | + ref: ${{ inputs.base_ref }} |
| 33 | + |
| 34 | + - name: Create merge commit |
| 35 | + env: |
| 36 | + GIT_AUTHOR_NAME: Bot |
| 37 | + GIT_AUTHOR_EMAIL: bot@bitbox.swiss |
| 38 | + GIT_COMMITTER_NAME: Bot |
| 39 | + GIT_COMMITTER_EMAIL: bot@bitbox.swiss |
| 40 | + run: | |
| 41 | + git fetch origin ${{ inputs.sha }} |
| 42 | + git merge --no-ff --no-edit ${{ inputs.sha }} |
| 43 | + echo "merge commit parents:" |
| 44 | + git log -1 --format=%P |
| 45 | +
|
| 46 | + - name: Pull container image |
| 47 | + run: ./.ci/run-container-ci pull |
| 48 | + |
| 49 | + - name: Run CI in container |
| 50 | + run: ./.ci/run-container-ci ${{github.workspace}} ${{ inputs.base_ref }} |
| 51 | + |
| 52 | + - name: Set status |
| 53 | + if: always() |
| 54 | + run: | |
| 55 | + curl -L -s \ |
| 56 | + -X POST \ |
| 57 | + -H "Accept: application/vnd.github+json" \ |
| 58 | + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ |
| 59 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 60 | + ${{ github.api_url }}/repos/${{ github.repository }}/statuses/${{ inputs.sha }} \ |
| 61 | + -d '{"state":"${{job.status}}","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","description":"The build ${{ job.status }}!","context":"ci / per-commit-build"}' |
0 commit comments