.github/workflows/e2e.go.schedule.main.config-ldflags-main-dir.slsa3.yml #1354
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| schedule: | |
| - cron: "0 10 * * *" | |
| workflow_dispatch: | |
| permissions: read-all | |
| concurrency: "e2e.go.schedule.main.config-ldflags-main-dir.slsa3" | |
| env: | |
| GH_TOKEN: ${{ secrets.E2E_GO_TOKEN }} | |
| ISSUE_REPOSITORY: slsa-framework/slsa-github-generator | |
| # WARNING: update build job if CONFIG_FILE changes. | |
| CONFIG_FILE: .github/configs-go/config-ldflags-main-dir.yml | |
| GO_MAIN: main.go | |
| GO_DIR: e2e/go | |
| jobs: | |
| args: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.ldflags.outputs.version }} | |
| commit: ${{ steps.ldflags.outputs.commit }} | |
| branch: ${{ steps.ldflags.outputs.branch }} | |
| main: ${{ steps.ldflags.outputs.main }} | |
| steps: | |
| - id: checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - id: ldflags | |
| run: | | |
| set -euo pipefail | |
| this_file=$(gh api -H "Accept: application/vnd.github.v3+json" "/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | jq -r '.path' | cut -d '/' -f3) | |
| branch=$(echo "${this_file}" | cut -d '.' -f4) | |
| { | |
| echo "version=-X main.gitVersion=v1.2.3" | |
| echo "commit=-X main.gitCommit=abcdef" | |
| echo "branch=-X main.gitBranch=${branch}" | |
| # Note: this must be the same path defined in the config file. | |
| echo "main=-X main.gitMain=${GO_MAIN}" | |
| } >> "${GITHUB_OUTPUT}" | |
| build: | |
| needs: [args] | |
| permissions: | |
| id-token: write # For signing. | |
| contents: write # For asset uploads. | |
| actions: read # For the entrypoint. | |
| uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@main | |
| with: | |
| go-version-file: "go.mod" | |
| # We cannot use ${{ env.CONFIG_FILE }} because env variables are not available. | |
| config-file: .github/configs-go/config-ldflags-main-dir.yml | |
| evaluated-envs: "VERSION:${{needs.args.outputs.version}},COMMIT:${{needs.args.outputs.commit}},BRANCH:${{needs.args.outputs.branch}},MAIN:${{needs.args.outputs.main}}" | |
| compile-builder: true | |
| # build: | |
| # runs-on: ubuntu-latest | |
| # steps: | |
| # - run: | | |
| # exit 1 | |
| verify: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: ${{ needs.build.outputs.go-binary-name }} | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: ${{ needs.build.outputs.go-binary-name }}.intoto.jsonl | |
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | |
| with: | |
| go-version: "1.24" | |
| - env: | |
| BINARY: ${{ needs.build.outputs.go-binary-name }} | |
| PROVENANCE: ${{ needs.build.outputs.go-binary-name }}.intoto.jsonl | |
| run: ./.github/workflows/scripts/e2e.go.default.verify.sh | |
| if-succeeded: | |
| runs-on: ubuntu-latest | |
| needs: [build, verify] | |
| # NOTE: The workflow is allowed to run for other event types but don't post | |
| # to issues unless it's a schedule event. | |
| if: github.event_name == 'schedule' && needs.build.result == 'success' && needs.verify.result == 'success' | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - run: ./.github/workflows/scripts/e2e-report-success.sh | |
| if-failed: | |
| runs-on: ubuntu-latest | |
| needs: [build, verify] | |
| # NOTE: The workflow is allowed to run for other event types but don't post | |
| # to issues unless it's a schedule event. | |
| if: always() && github.event_name == 'schedule' && (needs.build.result == 'failure' || needs.verify.result == 'failure') | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - run: ./.github/workflows/scripts/e2e-report-failure.sh |