Skip to content

Commit a45a2a6

Browse files
jeoyjeoy
authored andcommitted
🎉 init commit
1 parent 4b9dc0c commit a45a2a6

File tree

16 files changed

+710
-936
lines changed

16 files changed

+710
-936
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SKIP_PREFLIGHT_CHECK = true

.github/actions/deploy/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM node:10
2+
3+
LABEL "repository"="https://github.com/jeoy/github-deploy-actions"
4+
LABEL "maintainer"="jeoy <[email protected]>"
5+
6+
7+
ADD entrypoint.sh /entrypoint.sh
8+
9+
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

.github/actions/deploy/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'auto deploy action'
2+
description:
3+
'This action will auto deploy to target branch when it get triggered'
4+
author: 'jeoy <[email protected]>'
5+
runs:
6+
using: 'docker'
7+
image: 'Dockerfile'
8+
branding:
9+
icon: 'package'
10+
color: 'green'
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#! /bin/sh -l
2+
#! /bin/bash
3+
4+
set -e
5+
6+
if [ -z "$SECRET_TOKEN" ]
7+
then
8+
echo "SECRET_TOKEN is required"
9+
exit 1
10+
fi
11+
12+
if [ -z "$COMMIT_EMAIL" ]
13+
then
14+
echo "COMMIT_EMAIL is required"
15+
exit 1
16+
fi
17+
18+
if [ -z "$FOLDER" ]
19+
then
20+
echo "deploy FOLDER is required"
21+
exit 1
22+
fi
23+
24+
25+
apt-get update && \
26+
apt-get install -y git && \
27+
28+
29+
if [ -z "$COMMIT_NAME" ]
30+
then
31+
COMMIT_NAME="${GITHUB_ACTOR}"
32+
fi
33+
34+
# Directs the action to the the Github workspace.
35+
cd $GITHUB_WORKSPACE && \
36+
37+
# Configures Git.
38+
git init && \
39+
git config --global user.email "${COMMIT_EMAIL}" && \
40+
git config --global user.name "${COMMIT_NAME}" && \
41+
42+
43+
## Initializes the repository path using the access token.
44+
REPOSITORY_PATH="https://${SECRET_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" && \
45+
46+
47+
# Builds the project if a build script is provided.
48+
echo "-----------------------Running build scripts... ---------------"
49+
50+
eval "$BUILD_SCRIPT" && \
51+
52+
echo "---------checkout---to---${DEPLOY_BRANCH:-gh-pages}-----"
53+
git checkout --orphan "${DEPLOY_BRANCH:-gh-pages}" && \
54+
55+
git rm -rf . && \
56+
57+
if [ "$(git ls-remote --heads "$REPOSITORY_PATH" "${DEPLOY_BRANCH:-gh-pages}" | wc -l)" -ne 0 ];
58+
then
59+
echo "----- ${DEPLOY_BRANCH:-gh-pages} already exist-----sync origin----"
60+
git pull origin "${DEPLOY_BRANCH:-gh-pages}"
61+
fi
62+
63+
shopt -s extglob
64+
65+
rm -rf !($FOLDER) && cp -r $FOLDER/. ./ && rm -r $FOLDER && \
66+
67+
if [ -z "$(git status --porcelain)" ]; then
68+
echo "Nothing to deploy"
69+
else
70+
git add . && \
71+
72+
git commit -m "Deploying ${DEPLOY_BRANCH:-gh-pages} from ${BASE_BRANCH:-master} ${GITHUB_SHA}"
73+
74+
git push $REPOSITORY_PATH "${DEPLOY_BRANCH:-gh-pages}"
75+
fi
76+
77+
echo "------- deploy successful ----------- "

.github/workflows/deploy.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@master
14+
15+
- name: Build and Deploy
16+
uses: ./.github/actions/deploy
17+
env:
18+
COMMIT_EMAIL: [email protected]
19+
COMMIT_NAME: jeoy
20+
ACCESS_TOKEN: ${{ secrets.SECRET_TOKEN }}
21+
BASE_BRANCH: master # The branch the action should deploy from.
22+
DEPLOY_BRANCH: gh-pages # The branch the action should deploy to.
23+
FOLDER: build # The folder the action should deploy.
24+
BUILD_SCRIPT: yarn && yarn build # The build script the action should run prior to deploying.

README.md

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,9 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
1+
### This action will auto deploy to target branch when it get triggered
22

3-
## Available Scripts
3+
When push to `master` branch
44

5-
In the project directory, you can run:
5+
This Action will run `yarn && yarn build`
66

7-
### `npm start`
7+
Then push `build` folder as a new commit on `gh-pages` branch
88

9-
Runs the app in the development mode.<br>
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11-
12-
The page will reload if you make edits.<br>
13-
You will also see any lint errors in the console.
14-
15-
### `npm test`
16-
17-
Launches the test runner in the interactive watch mode.<br>
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19-
20-
### `npm run build`
21-
22-
Builds the app for production to the `build` folder.<br>
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
24-
25-
The build is minified and the filenames include the hashes.<br>
26-
Your app is ready to be deployed!
27-
28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29-
30-
### `npm run eject`
31-
32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33-
34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35-
36-
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37-
38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39-
40-
## Learn More
41-
42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43-
44-
To learn React, check out the [React documentation](https://reactjs.org/).
45-
46-
### Code Splitting
47-
48-
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49-
50-
### Analyzing the Bundle Size
51-
52-
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53-
54-
### Making a Progressive Web App
55-
56-
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57-
58-
### Advanced Configuration
59-
60-
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61-
62-
### Deployment
63-
64-
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65-
66-
### `npm run build` fails to minify
67-
68-
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
9+
> note: mark sure `build` folder is on your gitignore list

package.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
{
2-
"name": "github-deploy-actions",
3-
"version": "0.1.0",
4-
"private": true,
5-
"dependencies": {
6-
"react": "^16.9.0",
7-
"react-dom": "^16.9.0",
8-
"react-scripts": "3.1.2"
9-
},
10-
"scripts": {
11-
"start": "react-scripts start",
12-
"build": "react-scripts build",
13-
"test": "react-scripts test",
14-
"eject": "react-scripts eject"
15-
},
16-
"eslintConfig": {
17-
"extends": "react-app"
18-
},
19-
"browserslist": {
20-
"production": [
21-
">0.2%",
22-
"not dead",
23-
"not op_mini all"
24-
],
25-
"development": [
26-
"last 1 chrome version",
27-
"last 1 firefox version",
28-
"last 1 safari version"
29-
]
30-
}
2+
"name": "github-deploy-actions",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"react": "^16.9.0",
7+
"react-dom": "^16.9.0",
8+
"react-scripts": "3.1.1"
9+
},
10+
"scripts": {
11+
"start": "react-scripts start",
12+
"build": "react-scripts build",
13+
"test": "react-scripts test",
14+
"eject": "react-scripts eject"
15+
},
16+
"eslintConfig": {
17+
"extends": "react-app"
18+
},
19+
"browserslist": {
20+
"production": [
21+
">0.2%",
22+
"not dead",
23+
"not op_mini all"
24+
],
25+
"development": [
26+
"last 1 chrome version",
27+
"last 1 firefox version",
28+
"last 1 safari version"
29+
]
30+
}
3131
}

public/favicon.ico

-3.04 KB
Binary file not shown.

public/github-action-log.png

18.8 KB
Loading

public/logo192.png

10.4 KB
Loading

0 commit comments

Comments
 (0)