-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
73 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,25 +7,86 @@ on: | |
|
||
permissions: read-all | ||
|
||
env: | ||
IMAGE_REGISTRY: ghcr.io | ||
IMAGE_OWNER: equals215 | ||
IMAGE_NAME: deepsentinel-server | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
id-token: write # To sign. | ||
contents: write # To upload release assets. | ||
actions: read # To read workflow path. | ||
strategy: | ||
matrix: | ||
component: | ||
- server | ||
- agent | ||
os: | ||
- linux | ||
- darwin | ||
arch: | ||
- amd64 | ||
- arm64 | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] | ||
with: | ||
go-version: 1.22.2 | ||
config-file: .github/workflows/slsa3-configs/${{ matrix.component }}-${{ matrix.os }}-${{ matrix.arch }}.yml | ||
prerelease: true | ||
prerelease: true | ||
|
||
package: | ||
permissions: | ||
contents: read | ||
packages: write | ||
outputs: | ||
image: ${{ steps.image.outputs.image }} | ||
digest: ${{ steps.build.outputs.digest }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Authenticate Docker | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.IMAGE_REGISTRY }} | ||
username: ${{ env.IMAGE_OWNER }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: | | ||
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=tag | ||
type=sha | ||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
id: build | ||
with: | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
file: Dockerfile.server | ||
|
||
- name: Output image | ||
id: image | ||
run: | | ||
# NOTE: Set the image as an output because the `env` context is not | ||
# available to the inputs of a reusable workflow call. | ||
image_name="${IMAGE_REGISTRY}/${IMAGE_NAME}" | ||
echo "image=$image_name" >> "$GITHUB_OUTPUT" | ||
# This step calls the container workflow to generate provenance and push it to | ||
# the container registry. | ||
provenance: | ||
needs: [package] | ||
permissions: | ||
actions: read | ||
id-token: write | ||
packages: write | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] | ||
with: | ||
image: ${{ needs.package.outputs.image }} | ||
digest: ${{ needs.package.outputs.digest }} | ||
registry-username: ${{ github.actor }} | ||
secrets: | ||
registry-password: ${{ secrets.GITHUB_TOKEN }} |