-
-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (155 loc) · 6.02 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Docker CI
# 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
# documentation.
on:
schedule:
- cron: '30 22 * * *'
push:
pull_request:
branches: [ "main" ]
env:
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build-ci:
name: Build environment for GitLab CI/CD
runs-on: ubuntu-latest
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@v4
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.HUB_USERNAME }}
password: ${{ secrets.HUB_TOKEN }}
- name: Log into RHQCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.RHQCR_BOT_USERNAME }}
password: ${{ secrets.RHQCR_BOT_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ env.IMAGE_NAME }}/build-ci
quay.io/ajhalili2006/mkdocs-material-build-ci
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,enable=true,priority=100,prefix=commit-,suffix=,format=long
type=schedule,pattern=nightly
type=schedule,prefix=nightly-,pattern={{date 'YYYYMMDDhhmmss'}}
type=raw,prefix=branch-,value={{branch}}
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: docker/Dockerfile
# 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
id: build-and-push
uses: docker/build-push-action@v4.1.1
with:
context: docker
platforms: linux/amd64
#file: Dockerfile
# workaround: https://github.com/moby/buildkit/issues/2713#issuecomment-1068540101
push: true
#load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=registry,ref=quay.io/ajhalili2006/mkdocs-material-build-ci:buildkit-cache-web
type=registry,ref=quay.io/ajhalili2006/mkdocs-material-build-ci:branch-main
type=registry,ref=quay.io/ajhalili2006/mkdocs-material-build-ci:latest
#cache-to: type=registry,ref=quay.io/ajhalili2006/mkdocs-material-build-ci:buildkit-cache-web
devenv:
name: Generate Gitpod workspace image snapshot
runs-on: ubuntu-latest
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@v4
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.HUB_USERNAME }}
password: ${{ secrets.HUB_TOKEN }}
- name: Log into RHQCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: quay.io
username: ajhalili2006
password: ${{ secrets.RHQCR_PASSWORD }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ env.IMAGE_NAME }}/devenv
quay.io/gitpodified-workspace-images/mkdocs-deps
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,enable=true,priority=100,prefix=commit-,suffix=,format=long
type=schedule,pattern=nightly
type=schedule,prefix=nightly-,pattern={{date 'YYYYMMDDhhmmss'}}
type=raw,prefix=branch-,value={{branch}}
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: .gitpod.Dockerfile
# 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
id: build-and-push
uses: docker/build-push-action@v4.1.1
with:
context: .
file: .gitpod.Dockerfile
platforms: linux/amd64
# workaround: https://github.com/moby/buildkit/issues/2713#issuecomment-1068540101
push: true
#load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=registry,ref=quay.io/ajhalili2006/gitpod-workspace:buildkit-cache-web
type=registry,ref=ghcr.io/ajhalili2006/website/devenv:nightly
type=registry,ref=ghcr.io/ajhalili2006/website/devenv:branch-main
#cache-to: type=registry,ref=quay.io/ajhalili2006/gitpod-workspace:buildkit-cache-web