Last active
February 25, 2020 02:27
-
-
Save hirayama-bp/007c876373e3c804831198c8535767ff to your computer and use it in GitHub Desktop.
.github/workflows/ developでCI, masterでCDする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cd | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
cd: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: "12.x" | |
- name: get cache dir path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
id: yarn-cache-dir-path | |
- name: restore cache if exists | |
uses: actions/cache@v1 # python pipの時はここにサンプルがある https://github.com/actions/cache#implementation-examples | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- run: yarn install | |
working-directory: ./node | |
- name: run tests | |
run: yarn ci | |
working-directory: ./node | |
- name: set git config # gh-pagesブランチにpushするようにしているので、git configが必要 | |
run: | | |
git config user.name "<user>" | |
git config user.email "<email>" | |
git remote set-url origin https://<user>:[email protected]/<user>/<repo>.git | |
env: | |
GITHUB_TOKEN: ${{ github.token }} # actions/checkout@v2がトークンをセットしてくれるので、これでpushできる | |
- name: deploy to ph-pages | |
run: yarn cd | |
working-directory: ./node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: "12.x" | |
- name: get cache dir path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
id: yarn-cache-dir-path | |
- name: restore cache if exists | |
uses: actions/cache@v1 # python pipの時はここにサンプルがある https://github.com/actions/cache#implementation-examples | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- run: yarn install | |
working-directory: ./node | |
- name: run tests | |
run: yarn ci | |
working-directory: ./node |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment