Skip to content

Commit 4ddd09b

Browse files
authored
Create docker-publish-3d-memory.yaml
1 parent a0cdced commit 4ddd09b

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
schedule:
10+
- cron: '24 10 * * *'
11+
push:
12+
branches: [ "main" ]
13+
# Publish semver tags as releases.
14+
tags: [ 'v*.*.*' ]
15+
pull_request:
16+
branches: [ "main" ]
17+
18+
env:
19+
# Use docker.io for Docker Hub if empty
20+
REGISTRY: ghcr.io
21+
# github.repository as <account>/<repo>
22+
IMAGE_NAME: ${{ github.repository }}-3d-memory
23+
24+
25+
jobs:
26+
build:
27+
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: read
31+
packages: write
32+
# This is used to complete the identity challenge
33+
# with sigstore/fulcio when running outside of PRs.
34+
id-token: write
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v3
39+
with:
40+
submodules: 'true'
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
# Install the cosign tool except on PR
45+
# https://github.com/sigstore/cosign-installer
46+
- name: Install cosign
47+
if: github.event_name != 'pull_request'
48+
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
49+
with:
50+
cosign-release: 'v2.1.1'
51+
52+
# Set up BuildKit Docker container builder to be able to build
53+
# multi-platform images and export cache
54+
# https://github.com/docker/setup-buildx-action
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
57+
58+
# Login against a Docker registry except on PR
59+
# https://github.com/docker/login-action
60+
- name: Log into registry ${{ env.REGISTRY }}
61+
if: github.event_name != 'pull_request'
62+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
63+
with:
64+
registry: ${{ env.REGISTRY }}
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
68+
# Extract metadata (tags, labels) for Docker
69+
# https://github.com/docker/metadata-action
70+
- name: Extract Docker metadata
71+
id: meta
72+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
73+
with:
74+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
75+
76+
# Build and push Docker image with Buildx (don't push on PR)
77+
# https://github.com/docker/build-push-action
78+
- name: Build and push Docker image
79+
id: build-and-push
80+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
81+
with:
82+
context: .
83+
file: 3d-memory/Dockerfile
84+
push: ${{ github.event_name != 'pull_request' }}
85+
tags: ${{ steps.meta.outputs.tags }}
86+
labels: ${{ steps.meta.outputs.labels }}
87+
cache-from: type=gha
88+
cache-to: type=gha,mode=max
89+
90+
# Sign the resulting Docker image digest except on PRs.
91+
# This will only write to the public Rekor transparency log when the Docker
92+
# repository is public to avoid leaking data. If you would like to publish
93+
# transparency data even for private images, pass --force to cosign below.
94+
# https://github.com/sigstore/cosign
95+
- name: Sign the published Docker image
96+
if: ${{ github.event_name != 'pull_request' }}
97+
env:
98+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
99+
TAGS: ${{ steps.meta.outputs.tags }}
100+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
101+
# This step uses the identity token to provision an ephemeral certificate
102+
# against the sigstore community Fulcio instance.
103+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

0 commit comments

Comments
 (0)