Skip to content

Commit af4a591

Browse files
author
Lars Solberg
committed
Merge branch 'main' of github.com:opa-stack/opa-stack
2 parents 9ab3d5a + 8e4b78f commit af4a591

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Container
2+
3+
on:
4+
schedule:
5+
- cron: '32 11 * * *'
6+
push:
7+
branches: [ main ]
8+
tags: [ 'v*.*.*' ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
15+
16+
17+
jobs:
18+
build:
19+
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
id-token: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v3
29+
30+
# Install the cosign tool except on PR
31+
# https://github.com/sigstore/cosign-installer
32+
- name: Install cosign
33+
if: github.event_name != 'pull_request'
34+
uses: sigstore/cosign-installer@d6a3abf1bdea83574e28d40543793018b6035605
35+
with:
36+
cosign-release: 'v1.7.1'
37+
38+
39+
# Workaround: https://github.com/docker/build-push-action/issues/461
40+
- name: Setup Docker buildx
41+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
42+
43+
# Login against a Docker registry except on PR
44+
# https://github.com/docker/login-action
45+
- name: Log into registry ${{ env.REGISTRY }}
46+
if: github.event_name != 'pull_request'
47+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
48+
with:
49+
registry: ${{ env.REGISTRY }}
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
# Extract metadata (tags, labels) for Docker
54+
# https://github.com/docker/metadata-action
55+
- name: Extract Docker metadata
56+
id: meta
57+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
58+
with:
59+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60+
61+
# Build and push Docker image with Buildx (don't push on PR)
62+
# https://github.com/docker/build-push-action
63+
- name: Build and push Docker image
64+
id: build-and-push
65+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
66+
with:
67+
context: api
68+
push: ${{ github.event_name != 'pull_request' }}
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
file: api/Containerfile
72+
73+
# Sign the resulting Docker image digest except on PRs.
74+
# This will only write to the public Rekor transparency log when the Docker
75+
# repository is public to avoid leaking data. If you would like to publish
76+
# transparency data even for private images, pass --force to cosign below.
77+
# https://github.com/sigstore/cosign
78+
- name: Sign the published Docker image
79+
if: ${{ github.event_name != 'pull_request' }}
80+
env:
81+
COSIGN_EXPERIMENTAL: "true"
82+
# This step uses the identity token to provision an ephemeral certificate
83+
# against the sigstore community Fulcio instance.
84+
run: cosign sign ${{ steps.meta.outputs.tags }}@${{ steps.build-and-push.outputs.digest }}

0 commit comments

Comments
 (0)