-
Notifications
You must be signed in to change notification settings - Fork 1
164 lines (143 loc) · 4.3 KB
/
ci.yml
File metadata and controls
164 lines (143 loc) · 4.3 KB
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
name: CI
permissions:
id-token: write # Required for signing
contents: read
packages: write
attestations: write
pages: write
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
IMAGE: ghcr.io/${{ github.repository_owner }}/console-functions-plugin
jobs:
# --------
# CHECKS
# --------
checks:
name: Lint and Test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
cache: yarn
- name: Enable Corepack
run: corepack enable
- name: Install Dependencies
run: yarn install --immutable
- name: Lint
run: yarn lint
- name: Test
run: yarn test
# -----------
# BUILD IMAGE
# -----------
build-image:
name: Build Image
needs: checks
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- uses: docker/setup-qemu-action@v4
- uses: docker/setup-buildx-action@v4
- name: Build Image
uses: docker/build-push-action@v7
env:
SOURCE_DATE_EPOCH: 0
with:
context: .
push: false
provenance: false
# Multi-arch is required for OCP.
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
cache-from: type=gha
cache-to: type=gha,mode=max
# -------------
# PUBLISH IMAGE
# -------------
publish:
name: Publish Image
needs: build-image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
digest: ${{ steps.build-and-push.outputs.digest }}
steps:
- uses: actions/checkout@v6
- uses: docker/setup-qemu-action@v4
- uses: docker/setup-buildx-action@v4
- name: Login to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Image
id: build-and-push
uses: docker/build-push-action@v7
env:
SOURCE_DATE_EPOCH: 0
with:
context: .
push: true
provenance: false
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:sha-${{ github.sha }}
cache-from: type=gha
annotations: |
index:org.opencontainers.image.description=Serverless Functions Console Plugin for OpenShift
index:org.opencontainers.image.source=https://github.com/${{ github.repository }}
index:org.opencontainers.image.vendor=https://github.com/${{ github.repository }}
index:org.opencontainers.image.url=https://github.com/${{ github.repository }}/pkgs/container/console-functions-plugin
# Attestation is required for OCP.
- name: Attest Build Provenance
uses: actions/attest-build-provenance@v4
with:
subject-name: ${{ env.IMAGE }}
subject-digest: ${{ steps.build-and-push.outputs.digest }}
push-to-registry: true
# ------------
# DEPLOY PAGES
# ------------
deploy-pages:
name: Deploy Pages
needs: publish
runs-on: ubuntu-latest
timeout-minutes: 5
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v6
- name: Setup Helm
uses: azure/setup-helm@v5
- name: Generate deployment YAML and landing page
run: |
mkdir public
helm template console-functions-plugin charts/openshift-console-plugin \
-n console-functions-plugin \
--set "plugin.image=${{ env.IMAGE }}@${{ needs.publish.outputs.digest }}" \
> public/plugin.yaml
cp pages/index.html public/index.html
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: ./public
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5