Skip to content

Commit f9bfdc5

Browse files
committed
ci: add github workflow
1 parent 733842f commit f9bfdc5

4 files changed

Lines changed: 65 additions & 0 deletions

File tree

.docker/Dockerfile-build

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:20.12
2+
3+
RUN mkdir /app && chown -R node:node /app
4+
WORKDIR /app
5+
6+
USER node
7+
8+
COPY --from=ghcr.io/shk-webpr/ci-cd-github-dependencies:latest --chown=node:node /app .
9+
COPY --chown=node:node . .
10+
11+
RUN npm run build

.docker/Dockerfile-dependencies

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM node:20.12
2+
3+
RUN mkdir /app
4+
WORKDIR /app
5+
COPY package.json .
6+
COPY package-lock.json .
7+
8+
RUN npm ci

.dockerignore

Whitespace-only changes.

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
11+
jobs:
12+
dependencies:
13+
name: Install dependencies
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Docker login
18+
run: |
19+
echo ${{ secrets.PAT }} | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
20+
- name: Build and publish
21+
run: |
22+
docker build -f .docker/Dockerfile-dependencies -t ${{ env.REGISTRY }}/${{ github.repository }}-dependencies .
23+
docker push ${{ env.REGISTRY }}/${{ github.repository }}-dependencies
24+
build:
25+
name: Build application
26+
needs: dependencies
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: Docker login
31+
run: |
32+
echo ${{ secrets.PAT }} | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
33+
- name: Build and publish
34+
run: |
35+
id=$(docker create ${{ env.REGISTRY }}/${{ github.repository }}-dependencies)
36+
docker cp $id:/app - > .
37+
docker rm -v $id
38+
docker build -f .docker/Dockerfile-build -t ${{ env.REGISTRY }}/${{ github.repository }}-build:${{ github.sha }} .
39+
docker push ${{ env.REGISTRY }}/${{ github.repository }}-build:${{ github.sha }}
40+
deploy:
41+
name: Deploy application
42+
needs: build
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Fake deploy
46+
run: echo "Hello there, ${{ env.DEPLOY_USER }}"

0 commit comments

Comments
 (0)