Skip to content

Commit ebdedbf

Browse files
authored
Feature/ci (#423)
* ci(gh-actions): add github actions to fielstack-js * ci(gh-actions): update publish script
1 parent 2e8ba7c commit ebdedbf

File tree

4 files changed

+98
-5
lines changed

4 files changed

+98
-5
lines changed

.github/workflows/deploy.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: filestack-js
2+
on:
3+
create:
4+
tags:
5+
- v*
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
# - uses: voxmedia/github-action-slack-notify-build@v1
11+
# with:
12+
# channel: team-charlie
13+
# status: STARTED
14+
# color: good
15+
# env:
16+
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
17+
- uses: actions/checkout@v2
18+
- name: Setup repository env
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: '14.x'
22+
registry-url: "https://registry.npmjs.org"
23+
- name: Install deps
24+
run: npm install
25+
- name: Run tests
26+
run: npm test
27+
- name: Update code cov report
28+
run: npm run test:codecov
29+
- name: Prepare docs
30+
run: npm run docs
31+
- name: Publish package to cdn
32+
run: npm run publish:s3
33+
env:
34+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
35+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
36+
AWS_REGION: ${{ secrets.AWS_REGION }}
37+
- name: Publush to NPM (only on tag)
38+
run: npm publish --access public
39+
env:
40+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
- name: Deploy docs
42+
uses: crazy-max/ghaction-github-pages@v2
43+
with:
44+
target_branch: gh-pages
45+
build_dir: build/docs
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
# - name: Notify slack success
49+
# if: success()
50+
# env:
51+
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
52+
# uses: voxmedia/github-action-slack-notify-build@v1
53+
# with:
54+
# channel: team-charlie
55+
# status: SUCCESS
56+
# color: good
57+
# - name: Notify slack fail
58+
# if: failure()
59+
# env:
60+
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
61+
# uses: voxmedia/github-action-slack-notify-build@v1
62+
# with:
63+
# channel: team-charlie
64+
# status: FAILED
65+
# color: danger

.github/workflows/deploy_beta.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: filestack-js
2+
on:
3+
create:
4+
tags:
5+
- v*
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Setup repository env
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: '14.x'
15+
registry-url: "https://registry.npmjs.org"
16+
- name: Install deps
17+
run: npm install
18+
- name: Run tests
19+
run: npm test
20+
- name: Prepare docs
21+
run: npm run docs
22+
- name: Publish package to cdn - beta version
23+
run: npm run publish:s3:beta
24+
env:
25+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
26+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
27+
AWS_REGION: ${{ secrets.AWS_REGION }}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"docs:publish": "npm run docs && gh-pages -d build/docs",
3131
"release": "standard-version",
3232
"prepare": "npm run build",
33-
"publish:beta": "npm run build && node scripts/publish.js --beta",
34-
"publish": "npm run docs:publish && node scripts/publish.js --current --latest",
33+
"publish:s3:beta": "npm run build && node scripts/publish.js --beta",
34+
"publish:s3": "npm run docs:publish && node scripts/publish.js --current --latest",
3535
"cache:clean": "node scripts/cache.js --current --latest",
3636
"cache:clean:beta": "node scripts/cache.js --beta",
3737
"examples": "npm run build && node ./examples/examples.js"

scripts/publish.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const git = require('git-state');
1111

1212
const s3 = new AWS.S3();
1313
const DEPLOY_BRANCH = 'master';
14+
const repositoryExists = git.isGitSync(path);
15+
const currentBranch = git.checkSync(path);
16+
17+
console.log('CURRENT BRANCH IS: ', currentBranch);
1418

1519
const figureOutFileMimetype = (filePath) => {
1620
const type = mime.lookup(Path.extname(filePath));
@@ -50,14 +54,11 @@ const pushOneFileToS3 = (basePath, to, cacheControll = 1) => {
5054

5155
const canDeploy = () => {
5256
const path = './';
53-
const repositoryExists = git.isGitSync(path);
5457

5558
if (!repositoryExists) {
5659
throw new Error('Cannot read repository')
5760
}
5861

59-
const currentBranch = git.checkSync(path);
60-
6162
// if we cant get info about branch stop deploy
6263
if (!currentBranch) {
6364
throw new Error('Cant get info about branch');

0 commit comments

Comments
 (0)