diff --git a/.github/workflows/pre-submit.cli.yml b/.github/workflows/pre-submit.cli.yml index 71a1c1e..75c93e6 100644 --- a/.github/workflows/pre-submit.cli.yml +++ b/.github/workflows/pre-submit.cli.yml @@ -1,5 +1,12 @@ -name: Pre submits -on: [pull_request, workflow_dispatch] +name: Pre submits cli +on: + pull_request: + branches: [ "main" ] + workflow_dispatch: + # Used in combination with schedule.cli.yml + # to avoid duplicating the test code. + schedule: + - cron: '25 6 * * 5' permissions: read-all @@ -15,6 +22,17 @@ jobs: with: go-version: '1.18' + - name: Save event name + env: + EVENT_NAME: ${{ github.event_name }} + run: | + echo "$EVENT_NAME" > ./event_name.txt + + - uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # tag=v3.1.1 + with: + name: event_name + path: ./event_name.txt + - name: Run tests for verifier run: | set -euo pipefail diff --git a/.github/workflows/pre-submit.lint.yml b/.github/workflows/pre-submit.lint.yml index 4a73717..cad42fa 100644 --- a/.github/workflows/pre-submit.lint.yml +++ b/.github/workflows/pre-submit.lint.yml @@ -1,4 +1,4 @@ -name: Lint +name: Pre submits Lint on: [pull_request] diff --git a/.github/workflows/schedule.cli.yml b/.github/workflows/schedule.cli.yml new file mode 100644 index 0000000..6f37edf --- /dev/null +++ b/.github/workflows/schedule.cli.yml @@ -0,0 +1,39 @@ +name: Schedule cli +on: + workflow_run: + workflows: ["Pre submits cli"] + types: [completed] + branches: [main] + +permissions: read-all + +env: + GH_TOKEN: ${{ secrets.CREATE_ISSUES }} + ISSUE_REPOSITORY: ${{ github.repository }} + +jobs: + if-failed: + runs-on: ubuntu-latest + # See https://github.com/orgs/community/discussions/26238. + steps: + - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # tag=v1.10.0 + with: + name: event_name + - name: Check event name + id: name + run: | + name=$(cat ./event_name.txt) + ctned="false" + if [[ "$name" == "schedule" ]] || [[ "$name" == "workflow_dispatch" ]]; then + ctned="true" + fi + echo "continue=$ctned" >> $GITHUB_OUTPUT + - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # tag=v2.4.0 + if: steps.name.outputs.continue == 'true' + with: + ref: main + repository: slsa-framework/example-package + - run: ./.github/workflows/scripts/e2e-report-failure.sh + if: steps.name.outputs.continue == 'true' && github.event.workflow_run.conclusion != 'success' + - run: ./.github/workflows/scripts/e2e-report-success.sh + if: steps.name.outputs.continue == 'true' && github.event.workflow_run.conclusion == 'success'