Skip to content

Commit ee08971

Browse files
author
Daniel Pimenta
committed
Add ci
1 parent 63a0f3c commit ee08971

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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: '29 9 * * *'
11+
push:
12+
branches: [ "develop" ]
13+
# Publish semver tags as releases.
14+
tags: [ 'v*.*.*' ]
15+
pull_request:
16+
branches: [ "develop" ]
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 }}
23+
24+
jobs:
25+
build:
26+
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: read
30+
packages: write
31+
# This is used to complete the identity challenge
32+
# with sigstore/fulcio when running outside of PRs.
33+
id-token: write
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v3
38+
39+
# Install the cosign tool except on PR
40+
# https://github.com/sigstore/cosign-installer
41+
- name: Install cosign
42+
if: github.event_name != 'pull_request'
43+
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
44+
with:
45+
cosign-release: 'v1.13.1'
46+
47+
# Workaround: https://github.com/docker/build-push-action/issues/461
48+
- name: Setup Docker buildx
49+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
50+
51+
# Login against a Docker registry except on PR
52+
# https://github.com/docker/login-action
53+
- name: Log into registry ${{ env.REGISTRY }}
54+
if: github.event_name != 'pull_request'
55+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
56+
with:
57+
registry: ${{ env.REGISTRY }}
58+
username: ${{ github.actor }}
59+
password: ${{ secrets.GITHUB_TOKEN }}
60+
61+
# Extract metadata (tags, labels) for Docker
62+
# https://github.com/docker/metadata-action
63+
- name: Extract Docker metadata
64+
id: meta
65+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
66+
with:
67+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
68+
tags: |
69+
type=raw,value=develop
70+
type=ref,event=tag
71+
72+
# Build and push Docker image with Buildx (don't push on PR)
73+
# https://github.com/docker/build-push-action
74+
- name: Build and push Docker image
75+
id: build-and-push
76+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
77+
with:
78+
context: .
79+
file: ./Dockerfile.develop
80+
push: ${{ github.event_name != 'pull_request' }}
81+
tags: ${{ steps.meta.outputs.tags }}
82+
labels: ${{ steps.meta.outputs.labels }}
83+
cache-from: type=gha
84+
cache-to: type=gha,mode=max
85+
86+
87+
# Sign the resulting Docker image digest except on PRs.
88+
# This will only write to the public Rekor transparency log when the Docker
89+
# repository is public to avoid leaking data. If you would like to publish
90+
# transparency data even for private images, pass --force to cosign below.
91+
# https://github.com/sigstore/cosign
92+
- name: Sign the published Docker image
93+
if: ${{ github.event_name != 'pull_request' }}
94+
env:
95+
COSIGN_EXPERIMENTAL: "true"
96+
# This step uses the identity token to provision an ephemeral certificate
97+
# against the sigstore community Fulcio instance.
98+
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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: '29 9 * * *'
11+
push:
12+
branches: [ "master" ]
13+
# Publish semver tags as releases.
14+
tags: [ 'v*.*.*' ]
15+
pull_request:
16+
branches: [ "master" ]
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 }}
23+
24+
jobs:
25+
build:
26+
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: read
30+
packages: write
31+
# This is used to complete the identity challenge
32+
# with sigstore/fulcio when running outside of PRs.
33+
id-token: write
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v3
38+
39+
# Install the cosign tool except on PR
40+
# https://github.com/sigstore/cosign-installer
41+
- name: Install cosign
42+
if: github.event_name != 'pull_request'
43+
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
44+
with:
45+
cosign-release: 'v1.13.1'
46+
47+
# Workaround: https://github.com/docker/build-push-action/issues/461
48+
- name: Setup Docker buildx
49+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
50+
51+
# Login against a Docker registry except on PR
52+
# https://github.com/docker/login-action
53+
- name: Log into registry ${{ env.REGISTRY }}
54+
if: github.event_name != 'pull_request'
55+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
56+
with:
57+
registry: ${{ env.REGISTRY }}
58+
username: ${{ github.actor }}
59+
password: ${{ secrets.GITHUB_TOKEN }}
60+
61+
# Extract metadata (tags, labels) for Docker
62+
# https://github.com/docker/metadata-action
63+
- name: Extract Docker metadata
64+
id: meta
65+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
66+
with:
67+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
68+
tags: |
69+
type=raw,value=production
70+
type=ref,event=tag
71+
72+
# Build and push Docker image with Buildx (don't push on PR)
73+
# https://github.com/docker/build-push-action
74+
- name: Build and push Docker image
75+
id: build-and-push
76+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
77+
with:
78+
context: .
79+
file: ./Dockerfile.production
80+
push: ${{ github.event_name != 'pull_request' }}
81+
tags: ${{ steps.meta.outputs.tags }}
82+
labels: ${{ steps.meta.outputs.labels }}
83+
cache-from: type=gha
84+
cache-to: type=gha,mode=max
85+
86+
87+
# Sign the resulting Docker image digest except on PRs.
88+
# This will only write to the public Rekor transparency log when the Docker
89+
# repository is public to avoid leaking data. If you would like to publish
90+
# transparency data even for private images, pass --force to cosign below.
91+
# https://github.com/sigstore/cosign
92+
- name: Sign the published Docker image
93+
if: ${{ github.event_name != 'pull_request' }}
94+
env:
95+
COSIGN_EXPERIMENTAL: "true"
96+
# This step uses the identity token to provision an ephemeral certificate
97+
# against the sigstore community Fulcio instance.
98+
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}

0 commit comments

Comments
 (0)