File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 }}"
You can’t perform that action at this time.
0 commit comments