This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (74 loc) · 2.43 KB
/
cd.yml
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
name: Deploy
on:
push:
branches:
- main # Push to main branch
- ci-cd/*
jobs:
test:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v1
- name: "Set up node"
uses: actions/setup-node@v2
with:
node-version: 17.x
- name: "Run tests"
run: |
rm -rf node_modules && yarn install --frozen-lockfile
yarn run build --if-present
yarn test
publish:
runs-on: "ubuntu-latest"
needs: test
if: "contains(github.event.head_commit.message, 'trigger-cd') || contains(github.event.head_commit.message, 'Merge & deploy')"
steps:
- uses: actions/checkout@v1
- name: "Set up node"
uses: actions/setup-node@v2
with:
node-version: 17.x
- uses: actions/cache@v1
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json')}}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies from cache
run: |
yarn install --prefer-offline
- name: Install dependencies from repository
run: |
yarn install
- name: Generate production build
run: |
yarn build
- name: Build images
run: |
docker build -t ghcr.io/photonsquid/houseportal .
- name: Login to GitHub Packages
env:
TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
echo ${{ env.TOKEN }} | docker login ghcr.io -u photonsquid --password-stdin
- name: Push to GitHub Packages
id: push-to-gh-packages
run: |
tag=$(git rev-parse --short HEAD)
docker tag ghcr.io/photonsquid/houseportal ghcr.io/photonsquid/houseportal:$tag
docker push ghcr.io/photonsquid/houseportal:$tag
docker push ghcr.io/photonsquid/houseportal
echo ::set-output name=tag::$tag
- name: Logout
run: |
docker logout
- name: Create commit comment
uses: peter-evans/commit-comment@v2
with:
body: |
## Summary
✅ Commit successfully deployed to GitHub packages.
🔗 Commit reference: `${{ github.sha }}`
📦 Deployed image tag: `${{ steps.push-to-gh-packages.outputs.tag }}`
_This message was automatically generated by an action workflow._