-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from ianlewis/generic-branch-e2e
Add branch tests for generic workflow
- Loading branch information
Showing
14 changed files
with
442 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
2 changes: 1 addition & 1 deletion
2
.github/workflows/e2e.generic-bazel.schedule.main.default.slsa3.yml
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
.github/workflows/e2e.generic-bazel.workflow_dispatch.main.default.slsa3.yml
This file contains 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
128 changes: 128 additions & 0 deletions
128
.github/workflows/e2e.generic.push.branch1.default.slsa3.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
name: Generic push branch1 default SLSA3 | ||
|
||
on: | ||
schedule: | ||
- cron: "0 3 * * *" | ||
workflow_dispatch: | ||
push: | ||
branches: [branch1] | ||
|
||
permissions: read-all | ||
|
||
env: | ||
GH_TOKEN: ${{ secrets.E2E_GO_TOKEN }} | ||
ISSUE_REPOSITORY: slsa-framework/slsa-github-generator | ||
|
||
jobs: | ||
push: | ||
runs-on: ubuntu-latest | ||
if: github.ref_name == 'main' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 | ||
- run: ./.github/workflows/scripts/e2e-push.sh | ||
|
||
shim: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' | ||
outputs: | ||
continue: ${{ steps.verify.outputs.continue }} | ||
steps: | ||
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 | ||
- id: verify | ||
run: | | ||
set -euo pipefail | ||
source "./.github/workflows/scripts/e2e-utils.sh" | ||
THIS_FILE=$(e2e_this_file) | ||
BRANCH=$(echo "$THIS_FILE" | cut -d '.' -f4) | ||
if [[ "$BRANCH" == "$GITHUB_REF_NAME" ]]; then | ||
echo "::set-output name=continue::yes" | ||
fi | ||
build: | ||
needs: [shim] | ||
if: needs.shim.outputs.continue == 'yes' && github.event_name == 'push' && github.event.head_commit.message == github.workflow | ||
outputs: | ||
binary-name: ${{ steps.build.outputs.binary-name }} | ||
digest: ${{ steps.hash.outputs.digest }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup Go | ||
uses: actions/setup-go@f6164bd8c8acb4a71fb2791a8b6c4024ff038dab # v2.2.0 | ||
with: | ||
go-version: "1.18" | ||
- name: Build artifact | ||
id: build | ||
run: | | ||
go mod vendor | ||
go build -mod=vendor -o hello . | ||
echo "::set-output name=binary-name::hello" | ||
- name: Upload binary | ||
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v2.3.1 | ||
with: | ||
name: ${{ steps.build.outputs.binary-name }} | ||
path: ${{ steps.build.outputs.binary-name }} | ||
if-no-files-found: error | ||
retention-days: 5 | ||
- name: Generate hash | ||
shell: bash | ||
id: hash | ||
env: | ||
BINARY_NAME: ${{ steps.build.outputs.binary-name }} | ||
run: | | ||
set -euo pipefail | ||
echo "::set-output name=digest::$(sha256sum $BINARY_NAME | base64 -w0)" | ||
provenance: | ||
needs: [shim, build] | ||
if: needs.shim.outputs.continue == 'yes' && github.event_name == 'push' && github.event.head_commit.message == github.workflow | ||
permissions: | ||
id-token: write | ||
contents: read | ||
actions: read | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@main | ||
with: | ||
base64-subjects: "${{ needs.build.outputs.digest }}" | ||
|
||
verify: | ||
needs: [shim, build, provenance] | ||
runs-on: ubuntu-latest | ||
if: needs.shim.outputs.continue == 'yes' && github.event_name == 'push' && github.event.head_commit.message == github.workflow | ||
steps: | ||
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 | ||
- uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 | ||
with: | ||
name: ${{ needs.build.outputs.binary-name }} | ||
- uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 | ||
with: | ||
name: ${{ needs.provenance.outputs.attestation-name }} | ||
- uses: actions/setup-go@f6164bd8c8acb4a71fb2791a8b6c4024ff038dab # v2.2.0 | ||
with: | ||
go-version: "1.18" | ||
- env: | ||
BINARY: ${{ needs.build.outputs.binary-name }} | ||
PROVENANCE: ${{ needs.provenance.outputs.attestation-name }} | ||
run: ./.github/workflows/scripts/e2e.generic.default.verify.sh | ||
|
||
if-succeeded: | ||
runs-on: ubuntu-latest | ||
needs: [shim, build, provenance, verify] | ||
if: needs.shim.outputs.continue == 'yes' && github.event_name == 'push' && github.event.head_commit.message == github.workflow && needs.build.result == 'success' && needs.provenance.result == 'success' && needs.verify.result == 'success' | ||
steps: | ||
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 | ||
- run: ./.github/workflows/scripts/e2e-report-success.sh | ||
|
||
if-failed: | ||
runs-on: ubuntu-latest | ||
needs: [shim, build, provenance, verify] | ||
if: always() && needs.shim.outputs.continue == 'yes' && github.event_name == 'push' && github.event.head_commit.message == github.workflow && (needs.build.result == 'failure' || needs.provenance.result == 'failure' || needs.verify.result == 'failure') | ||
steps: | ||
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 | ||
- run: ./.github/workflows/scripts/e2e-report-failure.sh |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Generic schedule main default SLSA2 | ||
name: Generic schedule main default SLSA3 | ||
|
||
on: | ||
schedule: | ||
|
Oops, something went wrong.