Skip to content

Commit 0cb76be

Browse files
committed
🚚 Rename workflow to 🔄 CI/CD
to be more compliant with new functionalities
1 parent b15fb9b commit 0cb76be

File tree

3 files changed

+59
-66
lines changed

3 files changed

+59
-66
lines changed
Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33

4-
name: CI/CD and release
4+
name: 🔄 CI/CD
55

66
on:
77
push:
8-
branches: ["main"]
8+
branches: ["main", "beta", "*.*.*"]
99
pull_request:
10-
branches: ["main"]
10+
branches: ["main", "beta", "*.*.*"]
1111

1212
workflow_dispatch: # allow manual trigger
1313

@@ -16,7 +16,8 @@ on:
1616
merge_group:
1717

1818
env:
19-
APPLICATION_NAME: "docs"
19+
NAMESPACE_NAME: "docs"
20+
IMAGE_NAME: "docs"
2021

2122
jobs:
2223
build:
@@ -119,7 +120,7 @@ jobs:
119120
context: . # https://github.com/marketplace/actions/build-and-push-docker-images#git-context
120121
platforms: linux/amd64,linux/arm64
121122
push: true
122-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APPLICATION_NAME }}:latest
123+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
123124

124125
- name: 🐳 Build and push image ${{ needs.release.outputs.version }}
125126
uses: docker/build-push-action@v3
@@ -128,10 +129,10 @@ jobs:
128129
context: . # https://github.com/marketplace/actions/build-and-push-docker-images#git-context
129130
platforms: linux/amd64,linux/arm64
130131
push: true
131-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APPLICATION_NAME }}:${{ needs.release.outputs.version }}
132+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.version }}
132133

133134
deploy-prep:
134-
name: 🚀 Deploy to prep. latest
135+
name: 🚀 Deploy prep. [latest]
135136

136137
runs-on: ubuntu-latest
137138

@@ -142,30 +143,31 @@ jobs:
142143
url: https://prep.docs.sizeup.cloud
143144

144145
steps:
145-
- name: 🚀 Deploy latest to pre-production
146-
uses: actions-hub/kubectl@master
147-
env:
148-
KUBE_CONFIG: ${{ secrets.OCI_KUBE_CONFIG }}
146+
- name: ⚙️ Set up kubectl
147+
uses: tale/kubectl-action@v1
149148
with:
150-
args: rollout -n ${{ env.APPLICATION_NAME }} restart deployment ${{ env.APPLICATION_NAME }}-prep
149+
base64-kube-config: ${{ secrets.OCI_KUBE_CONFIG }}
150+
151+
- name: 🚀 Deploy to prep-production [latest]
152+
run: kubectl rollout -n ${{ env.NAMESPACE_NAME }} restart deployment ${{ env.NAMESPACE_NAME }}-prep
151153

152154
deploy-prod:
153-
name: 🚀 Deploy to prod. v${{ needs.release.outputs.version }}
155+
name: 🚀 Deploy prod. [v${{ needs.release.outputs.version }}]
154156

155157
runs-on: ubuntu-latest
156158

157159
needs: [release, push]
158160

159-
if: ${{ needs.release.outputs.version }} # deploy only if there is a new published version
161+
# deploy only if there is a new published version
162+
if: ${{ needs.release.outputs.version }}
160163

161-
environment:
162-
name: production # refer to https://github.com/size-up/docs/settings/environments
163-
url: https://docs.sizeup.cloud
164+
environment: production # refer to https://github.com/size-up/docs/settings/environments
164165

165166
steps:
166-
- name: 🚀 Deploy v${{ needs.release.outputs.version }} to production
167-
uses: actions-hub/kubectl@master
168-
env:
169-
KUBE_CONFIG: ${{ secrets.OCI_KUBE_CONFIG }}
167+
- name: ⚙️ Set up kubectl
168+
uses: tale/kubectl-action@v1
170169
with:
171-
args: set image -n ${{ env.APPLICATION_NAME }} deployment/${{ env.APPLICATION_NAME }}-prod ${{ env.APPLICATION_NAME }}-prod=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APPLICATION_NAME }}:${{ needs.release.outputs.version }}
170+
base64-kube-config: ${{ secrets.OCI_KUBE_CONFIG }}
171+
172+
- name: 🚀 Deploy to production [v${{ needs.release.outputs.version }}]
173+
run: kubectl set image -n ${{ env.NAMESPACE_NAME }} deployment/${{ env.IMAGE_NAME }}-prod ${{ env.IMAGE_NAME }}-prod=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.version }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is Cloud - Documentation website
22

3-
[![CI/CD and release](https://github.com/size-up/docs/actions/workflows/onPushMainPrMain.yaml/badge.svg?branch=main)](https://github.com/size-up/docs/actions/workflows/onPushMainPrMain.yaml)
3+
[![🔄 CI/CD](https://github.com/size-up/docs/actions/workflows/ci-cd.yaml/badge.svg?branch=main)](https://github.com/size-up/docs/actions/workflows/ci-cd.yaml)
44

55
![GitHub package.json version](https://img.shields.io/github/package-json/v/size-up/docs?label=application%20version) ![Docker Image Version (latest semver)](https://img.shields.io/docker/v/sizeup/docs?label=image%20version) ![Docker Image Size (latest semver)](https://img.shields.io/docker/image-size/sizeup/docs)
66

docs/github/actions/real-world.md

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,31 @@ sidebar_position: 999
88
This example is directly inspired from the `docs` repository _(where you are connected_ 🤯*)*.
99
:::
1010

11-
```yaml title="onPushMainPrMain.yaml"
11+
```yaml title="ci-cd.yaml"
1212
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
1313
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
1414

15-
name: CI/CD and release
15+
name: 🔄 CI/CD
1616

1717
on:
1818
push:
19-
branches: ["main"]
19+
branches: ["main", "beta", "*.*.*"]
2020
pull_request:
21-
branches: ["main"]
21+
branches: ["main", "beta", "*.*.*"]
22+
23+
workflow_dispatch: # allow manual trigger
24+
25+
# Used by the GitHub merge queue feature.
26+
# Documentation: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue
27+
merge_group:
2228

2329
env:
24-
APPLICATION_NAME: "docs"
30+
NAMESPACE_NAME: "docs"
31+
IMAGE_NAME: "docs"
2532

2633
jobs:
2734
build:
28-
name: ⚙️ Build application
35+
name: ⚙️ Build
2936

3037
runs-on: ubuntu-latest
3138

@@ -53,24 +60,20 @@ jobs:
5360
- name: ⚙️ Build application
5461
run: yarn run build
5562

56-
- name: 📤 Upload build artifact
57-
uses: actions/upload-artifact@v3
58-
with:
59-
name: build
60-
path: ./build
61-
6263
- if: steps.yarn-cache.outputs.cache-hit != 'true'
6364
name: 🗃 List the state of node modules
6465
continue-on-error: true
6566
run: yarn list
6667

6768
release:
68-
name: 🔖 Release application
69+
name: 🔖 Release
6970

7071
runs-on: ubuntu-latest
7172

7273
needs: build
7374

75+
if: ${{ github.event_name != 'merge_group' }} # skip this job if the event is a merge_group
76+
7477
steps:
7578
- name: 📥 Checkout repository
7679
uses: actions/checkout@v3
@@ -112,12 +115,6 @@ jobs:
112115
- name: 📥 Checkout repository
113116
uses: actions/checkout@v3
114117

115-
- name: 📥 Download build artifact
116-
uses: actions/download-artifact@v3
117-
with:
118-
name: build
119-
path: ./build
120-
121118
- name: ⚙️ Set up QEMU
122119
uses: docker/setup-qemu-action@v2
123120
- name: 🛠 Set up Docker Buildx
@@ -134,7 +131,7 @@ jobs:
134131
context: . # https://github.com/marketplace/actions/build-and-push-docker-images#git-context
135132
platforms: linux/amd64,linux/arm64
136133
push: true
137-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APPLICATION_NAME }}:latest
134+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
138135

139136
- name: 🐳 Build and push image ${{ needs.release.outputs.version }}
140137
uses: docker/build-push-action@v3
@@ -143,10 +140,10 @@ jobs:
143140
context: . # https://github.com/marketplace/actions/build-and-push-docker-images#git-context
144141
platforms: linux/amd64,linux/arm64
145142
push: true
146-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APPLICATION_NAME }}:${{ needs.release.outputs.version }}
143+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.version }}
147144

148145
deploy-prep:
149-
name: 🚀 Deploy latest to prep.
146+
name: 🚀 Deploy prep. [latest]
150147

151148
runs-on: ubuntu-latest
152149

@@ -157,38 +154,32 @@ jobs:
157154
url: https://prep.docs.sizeup.cloud
158155

159156
steps:
160-
- name: 🚀 Deploy latest to pre-production
161-
uses: actions-hub/kubectl@master
162-
env:
163-
KUBE_CONFIG: ${{ secrets.OCI_KUBE_CONFIG }}
157+
- name: ⚙️ Set up kubectl
158+
uses: tale/kubectl-action@v1
164159
with:
165-
args: rollout -n ${{ env.APPLICATION_NAME }} restart deployment ${{ env.APPLICATION_NAME }}-prep
160+
base64-kube-config: ${{ secrets.OCI_KUBE_CONFIG }}
161+
162+
- name: 🚀 Deploy to prep-production [latest]
163+
run: kubectl rollout -n ${{ env.NAMESPACE_NAME }} restart deployment ${{ env.NAMESPACE_NAME }}-prep
166164

167165
deploy-prod:
168-
name: 🚀 Deploy v${{ needs.release.outputs.version }} to prod.
166+
name: 🚀 Deploy prod. [v${{ needs.release.outputs.version }}]
169167

170168
runs-on: ubuntu-latest
171169

172170
needs: [release, push]
173171

174-
if: ${{ needs.release.outputs.version }} # deploy only if there is a new published version
172+
# deploy only if there is a new published version
173+
if: ${{ needs.release.outputs.version }}
175174

176-
environment:
177-
name: production # refer to https://github.com/size-up/docs/settings/environments
178-
url: https://docs.sizeup.cloud
175+
environment: production # refer to https://github.com/size-up/docs/settings/environments
179176

180177
steps:
181-
- name: ⚙️ Set tag image
182-
uses: actions-hub/kubectl@master
183-
env:
184-
KUBE_CONFIG: ${{ secrets.OCI_KUBE_CONFIG }}
178+
- name: ⚙️ Set up kubectl
179+
uses: tale/kubectl-action@v1
185180
with:
186-
args: set image -n ${{ env.APPLICATION_NAME }} deployment/${{ env.APPLICATION_NAME }}-prod ${{ env.APPLICATION_NAME }}-prod=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APPLICATION_NAME }}:${{ needs.release.outputs.version }}
181+
base64-kube-config: ${{ secrets.OCI_KUBE_CONFIG }}
187182

188-
- name: 🚀 Deploy v${{ needs.release.outputs.version }} to production
189-
uses: actions-hub/kubectl@master
190-
env:
191-
KUBE_CONFIG: ${{ secrets.OCI_KUBE_CONFIG }}
192-
with:
193-
args: rollout -n ${{ env.APPLICATION_NAME }} restart deployment ${{ env.APPLICATION_NAME }}-prod
183+
- name: 🚀 Deploy to production [v${{ needs.release.outputs.version }}]
184+
run: kubectl set image -n ${{ env.NAMESPACE_NAME }} deployment/${{ env.IMAGE_NAME }}-prod ${{ env.IMAGE_NAME }}-prod=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.version }}
194185
```

0 commit comments

Comments
 (0)