-
-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (156 loc) · 4.86 KB
/
main.yaml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: main
on:
push:
branches:
- '*'
schedule:
- cron: "0 23 * * 0" # weekly on Sunday evening
repository_dispatch:
jobs:
npm:
name: Update npm
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v3
with:
ref: ${{github.ref_name}}
-
name: Setup npm
uses: actions/setup-node@v3
-
name: Checking updates for package-lock.json
run: npm update
-
name: add and commit changes for package-lock.json
uses: EndBug/add-and-commit@v9
with:
# The arguments for the `git add` command (see the paragraph below for more info)
# Default: '.'
add: 'package-lock.json'
# Additional arguments for the git commit command. The --message argument is already set by the message input.
# Default: ''
commit: --signoff
# Determines the way the action fills missing author name and email. Three options are available:
# - github_actor -> UserName <UserName@users.noreply.github.com>
# - user_info -> Your Display Name <your-actual@email.com>
# - github_actions -> github-actions <email associated with the github logo>
# Default: github_actor
default_author: github_actor
# The message for the commit.
# Default: 'Commit from GitHub Actions (name of the workflow)'
message: '[automatic] updated package-lock.json'
# The way the action should handle pathspec errors from the add and remove commands. Three options are available:
# - ignore -> errors will be logged but the step won't fail
# - exitImmediately -> the action will stop right away, and the step will fail
# - exitAtEnd -> the action will go on, every pathspec error will be logged at the end, the step will fail.
# Default: ignore
pathspec_error_handling: ignore
test:
name: Run tests
runs-on: ubuntu-latest
needs: npm
steps:
-
uses: actions/checkout@v3
with:
ref: ${{github.ref_name}}
-
name: Setup npm
uses: actions/setup-node@v3
-
name: install project
run: npm install
-
name: Run tests
run: echo "TODO"
-
name: generate coverage report
run: echo "TODO" #coverage xml -i # creates coverage.xml
-
name: Upload coverage data to coveralls.io
run: echo "TODO" #coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
artifact:
name: Build artifacts
runs-on: ubuntu-latest
needs: test
if: github.ref_name == 'master'
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.ref_name}}
-
name: Setup npm
uses: actions/setup-node@v3
-
name: install project
run: npm install
-
name: Build artifacts dev
run: npm run build-dev
-
name: zip artifacts
run: pushd dist/misinfome-frontend-v2 && zip -r ../app-dev.zip . && popd
-
name: Build artifacts release
run: npm run build
-
name: zip artifacts
run: pushd dist/misinfome-frontend-v2 && zip -r ../app.zip . && popd
-
name: Get current date # for tagging the image, can go back in time if latest is problematic
id: date
run: echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
-
name: Release ${{ env.TODAY }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.TODAY }}
files: |
dist/app.zip
dist/app-dev.zip
-
name: delete release "latest"
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { owner, repo } = context.repo
const { data: { id } } = await github.repos.getReleaseByTag({ owner, repo, tag: "latest" })
await github.repos.deleteRelease({ owner, repo, release_id: id })
-
name: Release "latest" again
uses: softprops/action-gh-release@v1
with:
tag_name: latest
files: |
dist/app.zip
dist/app-dev.zip
update-main-repo:
name: Update main repo
runs-on: ubuntu-latest
needs: artifact
if: github.ref_name == 'master' # already checked in docker job
permissions: write-all
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.ref_name}}
-
name: Get current sha
id: sha
run: echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
-
name: trigger main repo
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.MISINFOME_GH_TOKEN }}
repository: MartinoMensio/MisinfoMe
event-type: 'Update: ${{ github.event.repository.name }}'
client-payload: '{ "submodule": "frontend-v2" , "repository": "${{ github.event.repository.name }}", "commit_sha": "${{ env.SHA }}" }'