From 5db25f8410d45c9ddbc61a1988dd2eb484366a18 Mon Sep 17 00:00:00 2001 From: Kasper Skytte Andersen Date: Fri, 21 Jul 2023 10:30:43 +0200 Subject: [PATCH] Update docker-rstudio-server.yml --- .github/workflows/docker-rstudio-server.yml | 48 +++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-rstudio-server.yml b/.github/workflows/docker-rstudio-server.yml index 9173ca66..2bfd0dae 100644 --- a/.github/workflows/docker-rstudio-server.yml +++ b/.github/workflows/docker-rstudio-server.yml @@ -1,3 +1,5 @@ +name: Docker + # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support @@ -5,7 +7,7 @@ on: schedule: - - cron: '29 22 * * *' + - cron: '20 11 * * *' push: branches: - main @@ -13,11 +15,7 @@ on: # Publish semver tags as releases. tags: [ 'v*.*.*' ] pull_request: - branches: - - main - - development - -name: RStudio-ampvis2 + branches: [ "main" ] env: # Use docker.io for Docker Hub if empty @@ -33,10 +31,25 @@ jobs: permissions: contents: read packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 + with: + cosign-release: 'v2.1.1' + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf # Login against a Docker registry except on PR # https://github.com/docker/login-action @@ -59,9 +72,28 @@ jobs: # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a with: context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable + TAGS: ${{ steps.meta.outputs.tags }} + DIGEST: ${{ steps.build-and-push.outputs.digest }} + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}