-
-
Notifications
You must be signed in to change notification settings - Fork 32
146 lines (141 loc) · 4.74 KB
/
ci.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
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
name: Continuous integration
on:
pull_request:
branches:
- '**'
push:
branches: [master]
tags:
- '**'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
node-version: [lts/*]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: npm install, lint and build
run: |
npm ci
npm run lint:no-fix
npm run build
env:
CI: ${{ true }}
- name: Docker meta
id: docker_meta
if: "contains(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'"
uses: docker/[email protected]
with:
# list of Docker images to use as base name for tags
images: c2corg/c2c_ui
- name: Login to DockerHub
if: "contains(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker images
if: "contains(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'"
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
- name: Create clean branch name
id: clean_branch
run: echo ::set-output name=CLEAN_BRANCH::${BRANCH/\//-}
env:
BRANCH: ${{ steps.branch-name.outputs.current_branch }}
- name: Build for github pages
run: npm run build:github
env:
GITHUB_PAGES_BRANCH: ${{ steps.clean_branch.outputs.CLEAN_BRANCH }}
- name: Upload artifact for github pages
uses: actions/upload-artifact@v4
with:
name: github-pages
path: dist/*
github-pages:
needs: build
if: "!github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]'"
runs-on: ubuntu-latest
concurrency: github-pages
permissions:
contents: write
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
- name: Create clean branch name
id: clean_branch
run: echo ::set-output name=CLEAN_BRANCH::${BRANCH/\//-}
env:
BRANCH: ${{ steps.branch-name.outputs.current_branch || steps.branch-name.outputs.tag }}
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Remove current branch files
run: rm -rf ${{ steps.clean_branch.outputs.CLEAN_BRANCH }}
- name: Retrieve github pages artifact
uses: actions/download-artifact@v4
with:
name: github-pages
path: ${{ steps.clean_branch.outputs.CLEAN_BRANCH }}
- name: Commit files
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add .
git commit -m "Deploy ${{ steps.branch-name.outputs.current_branch }} branch"
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
create-release:
needs: build
if: "startsWith(github.ref, 'refs/tags/v')"
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create or update release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
push-i18n:
needs: build
if: "github.ref == 'refs/heads/master' && github.repository == 'c2corg/c2c_ui'"
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Push translations to Transifex
run: |
echo "::add-mask::$TOKEN"
npm i
npm run messages:extract
curl --location --fail --request POST 'https://rest.api.transifex.com/resource_strings_async_uploads' --header 'Content-Type: multipart/form-data' --header "Authorization: Bearer $TOKEN" --form 'content=@"src/translations/c2corg_ui-client.pot"' --form 'resource="o:camptocamp-association:p:c2corg_ui:r:main"'
env:
TOKEN: ${{ secrets.TRANSIFEX_TOKEN }}