Skip to content

Commit 4fece3e

Browse files
Add 'test-and-build' gh action workflow
1 parent 6c30438 commit 4fece3e

File tree

4 files changed

+74
-60
lines changed

4 files changed

+74
-60
lines changed

.ci/Taskfile.yaml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,42 @@ tasks:
88
cmds:
99
- cp .env.example .env
1010

11+
root:yarn:
12+
desc: runs 'yarn' in root directory
13+
cmds:
14+
- |
15+
docker run \
16+
--rm \
17+
-w /app \
18+
-v $(pwd)/..:/app \
19+
$NODE_IMAGE yarn
20+
21+
docs:yarn:
22+
desc: runs 'yarn' in 'docs' directory
23+
cmds:
24+
- |
25+
docker run \
26+
--rm \
27+
-w /app \
28+
-v $(pwd)/../docs:/app \
29+
$NODE_IMAGE yarn
30+
31+
lib:yarn:
32+
desc: runs 'yarn' in 'lib' directory
33+
cmds:
34+
- |
35+
docker run \
36+
--rm \
37+
-w /app \
38+
-v $(pwd)/../lib:/app \
39+
$NODE_IMAGE yarn
40+
41+
yarn:
42+
cmds:
43+
- task root:yarn
44+
- task docs:yarn
45+
- task lib:yarn
46+
1147
lint:
1248
cmds:
1349
- |
@@ -27,7 +63,7 @@ tasks:
2763
$NODE_IMAGE \
2864
yarn test:unit
2965
30-
build:
66+
build:prepare:
3167
desc: creates production build of docs
3268
cmds:
3369
- |
@@ -38,6 +74,12 @@ tasks:
3874
-v $(pwd)/../lib:/app/lib \
3975
$NODE_IMAGE /bin/bash -c "yarn build"
4076
77+
build:
78+
cmds:
79+
- task lint
80+
- task test
81+
- task build:prepare
82+
4183
deploy:pages:
4284
desc: deploy to CloudFlare pages
4385
cmds:
@@ -53,7 +95,5 @@ tasks:
5395
deploy:
5496
desc: Lints, tests, builds and deploys to CloudFlare pages
5597
cmds:
56-
- task lint
57-
- task test
5898
- task build
5999
- task deploy:pages

.github/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The Supersonic Plugin For Scroll Based Animation
22

3-
![test-and-build](https://github.com/the-illarionov/the-superawesome-frontend-boilerplate/actions/workflows/test-and-build.yml/badge.svg)
4-
![deploy](https://github.com/the-illarionov/the-superawesome-frontend-boilerplate/actions/workflows/deploy.yml/badge.svg)
3+
![test-and-build](https://github.com/the-illarionov/the-supersonic-plugin-for-scroll-based-animation/actions/workflows/test-and-build.yml/badge.svg)
4+
![deploy](https://github.com/the-illarionov/the-supersonic-plugin-for-scroll-based-animation/actions/workflows/deploy.yml/badge.svg)
55

66
![gzip size](https://img.shields.io/bundlejs/size/the-supersonic-plugin-for-scroll-based-animation)
77

.github/workflows/deploy.yml

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,27 @@ jobs:
3737
run_id: successfulRunId,
3838
});
3939
40-
const artifactFrontendId = allArtifacts.data.artifacts.find((artifact) => artifact.name == "frontend-dist").id;
40+
const artifactId = allArtifacts.data.artifacts.find((artifact) => artifact.name == "docs-dist").id;
4141
42-
const artifactBackendId = allArtifacts.data.artifacts.find((artifact) => artifact.name == "backend-dist").id;
43-
44-
const downloadFrontend = await github.rest.actions.downloadArtifact({
42+
const downloadArtifact = await github.rest.actions.downloadArtifact({
4543
owner: context.repo.owner,
4644
repo: context.repo.repo,
47-
artifact_id: artifactFrontendId,
48-
archive_format: 'zip',
49-
});
50-
51-
const downloadBackend = await github.rest.actions.downloadArtifact({
52-
owner: context.repo.owner,
53-
repo: context.repo.repo,
54-
artifact_id: artifactBackendId,
45+
artifact_id: artifactId,
5546
archive_format: 'zip',
5647
});
5748
5849
let fs = require('fs');
59-
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/frontend.zip`, Buffer.from(downloadFrontend.data));
60-
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/backend.zip`, Buffer.from(downloadBackend.data));
50+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/docs.zip`, Buffer.from(downloadFrontend.data));
6151
6252
- name: Unzip artifacts
6353
run: |
64-
unzip frontend.zip -d frontend/dist
65-
unzip backend.zip -d backend/dist
54+
unzip docs.zip -d dist
6655
67-
# Example of deploying to Cloudflare
68-
# - name: Deploy 'frontend/dist' to Cloudflare Pages
69-
# uses: cloudflare/pages-action@v1
70-
# with:
71-
# apiToken: your-token
72-
# accountId: your-account-id
73-
# projectName: your-project-name
74-
# workingDirectory: frontend
75-
# directory: dist
76-
# branch: main
56+
- name: Deploy to Cloudflare Pages
57+
uses: cloudflare/pages-action@v1
58+
with:
59+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
60+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
61+
projectName: the-supersonic-plugin-for-scroll-based-animation
62+
directory: dist
63+
branch: main

.github/workflows/test-and-build.yml

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,15 @@ jobs:
2323
- name: Prepare env
2424
run: task -d .ci env
2525

26-
- name: Initialize everything
27-
run: task -d .ci init
28-
29-
- name: Lint
30-
run: task -d .ci root:lint
31-
3226
- name: 'Cache node_modules: check'
3327
uses: actions/cache/restore@v4
3428
id: cache-node-modules
3529
with:
3630
path: |
37-
frontend/node_modules
38-
backend/node_modules
39-
key: node-modules-${{ hashFiles('frontend/yarn.lock', 'backend/yarn.lock') }}
31+
node_modules
32+
docs/node_modules
33+
lib/node_modules
34+
key: node-modules-${{ hashFiles('yarn.lock', 'docs/yarn.lock', 'lib/yarn.lock') }}
4035

4136
- if: steps.cache-node-modules.outputs.cache-hit != 'true'
4237
name: 'Cache node_modules doesn''t exist: install'
@@ -47,30 +42,22 @@ jobs:
4742
uses: actions/cache/save@v4
4843
with:
4944
path: |
50-
frontend/node_modules
51-
backend/node_modules
52-
key: node-modules-${{ hashFiles('frontend/yarn.lock', 'backend/yarn.lock') }}
53-
54-
- name: Set permissions for node_modules
55-
run: sudo chmod -R 777 frontend/node_modules
56-
57-
- name: Build 'frontend' and 'backend'
58-
run: task -d .ci build
45+
node_modules
46+
docs/node_modules
47+
lib/node_modules
48+
key: node-modules-${{ hashFiles('yarn.lock', 'docs/yarn.lock', 'lib/yarn.lock') }}
5949

60-
- name: Start project
61-
run: task -d .ci up
50+
- name: Lint workspace
51+
run: task -d .ci lint
6252

63-
- name: Starts testing
53+
- name: Unit tests lib
6454
run: task -d .ci test
6555

66-
- name: 'Uploads ''frontend/dist'' artifact'
67-
uses: actions/upload-artifact@v4
68-
with:
69-
path: frontend/dist
70-
name: frontend-dist
56+
- name: Build docs
57+
run: task -d .ci build:prepare
7158

72-
- name: 'Uploads ''backend/dist'' artifact'
59+
- name: 'Uploads ''frontend/dist'' artifact'
7360
uses: actions/upload-artifact@v4
7461
with:
75-
path: backend/dist
76-
name: backend-dist
62+
path: docs/dist
63+
name: docs-dist

0 commit comments

Comments
 (0)