Skip to content

Commit 5c85cf0

Browse files
chore(.github): add release cd (#3)
1 parent 01054e9 commit 5c85cf0

File tree

8 files changed

+2378
-1
lines changed

8 files changed

+2378
-1
lines changed

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and Push
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
commitlint:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
14+
with:
15+
fetch-depth: 0
16+
- name: Validate HEAD Commit
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
- run: |
21+
npm i
22+
npx commitlint --from HEAD~1 --to HEAD --verbose
23+
24+
build:
25+
needs: commitlint
26+
runs-on: ubuntu-22.04
27+
# Only run the release job if the commit message suggests a release:
28+
# It is assumed commits starting with "chore" | "refactor" | "docs" do not warrant a release
29+
if: ${{ contains(fromJSON('["!:", "BREAKING CHANGE:", "patch", "minor", "major"]'), github.event.head_commit.message) || !(startsWith('chore', github.event.head_commit.message) || startsWith('refactor', github.event.head_commit.message) || startsWith('docs', github.event.head_commit.message)) }}
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
33+
34+
- name: Login to GHCR
35+
uses: docker/login-action@v2
36+
with:
37+
registry: ghcr.io
38+
username: ${{ secrets.DOCKERHUB_USERNAME }}
39+
password: ${{ secrets.DOCKERHUB_TOKEN }}
40+
41+
- name: Tag Version
42+
uses: actions/setup-node@v3
43+
with:
44+
node-version: 18
45+
- run: |
46+
npm i
47+
NEW_VERSION=$(node scripts/version.js "$COMMIT_MESSAGE")
48+
echo "New version: $NEW_VERSION"
49+
# Split NEW_VERSION into an array, using '.' as the delimiter
50+
IFS='.' read -ra VERSION <<< "$NEW_VERSION"
51+
PUBLISH_TAG_VERSION_MAJOR=${VERSION[0]}
52+
PUBLISH_TAG_VERSION_MINOR=${VERSION[1]}
53+
PUBLISH_TAG_VERSION_PATCH=${VERSION[2]}
54+
export PUBLISH_TAG_VERSION_MAJOR PUBLISH_TAG_VERSION_MINOR PUBLISH_TAG_VERSION_PATCH
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
58+
59+
- name: Build
60+
run: make build
61+
62+
- name: Push
63+
run: make push

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.vscode
2+
node_modules

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# freeCodeCamp/gitpod-images
2+
3+
## Release
4+
5+
On pushes to `main`, a GitHub Action will build and push the images to Docker Hub. The image tags will be the same as the Git tag associated with the commit.
6+
7+
### Create a Commit with Git Tag
8+
9+
```bash
10+
git tag -a v1.0.0 -m "Release v1.0.0"
11+
git push origin v1.0.0
12+
```

base/Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GitPod Dockerfile have non standard format for tags, we use latest and then we use our own tag
1+
# Gitpod Dockerfile have non standard format for tags, we use latest and then we use our own tag
22
FROM gitpod/workspace-base:latest
33
USER gitpod
44

@@ -8,6 +8,9 @@ ENV TRIGGER_REBUILD=1
88
ARG MONGOSH_VERSION=1.8.0
99
ARG MONGODB_VERSION=6.0.4
1010
ARG UBUNTU_VERSION=ubuntu2204
11+
ARG NODE_VERSION=18
12+
ARG NVM_VERSION=0.39.3
13+
ARG PNPM_VERSION=8
1114

1215
RUN echo "Installing MongoDB $MONGODB_VERSION and MongoSH $MONGOSH_VERSION"
1316

@@ -31,3 +34,12 @@ RUN mkdir -p /tmp/mongodb && \
3134
rm -rf /tmp/mongodb && \
3235
sudo mkdir -p /data/db && \
3336
sudo chown gitpod:gitpod -R /data/db
37+
38+
# from https://www.gitpod.io/docs/introduction/languages/javascript#node-versions
39+
# install nvm
40+
RUN bash -c 'wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash \
41+
&& source $HOME/.nvm/nvm.sh && nvm install $NODE_VERSION \
42+
&& nvm use $NODE_VERSION && nvm alias default $NODE_VERSION \
43+
&& npm i -g pnpm@$PNPM_VERSION'
44+
45+
RUN echo "nvm use default &>/dev/null" >> ~/.bashrc.d/51-nvm-fix

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ["@commitlint/config-conventional"] };

0 commit comments

Comments
 (0)