Skip to content

Instantly share code, notes, and snippets.

@hirayama-bp
Last active February 25, 2020 02:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirayama-bp/007c876373e3c804831198c8535767ff to your computer and use it in GitHub Desktop.
Save hirayama-bp/007c876373e3c804831198c8535767ff to your computer and use it in GitHub Desktop.
.github/workflows/ developでCI, masterでCDする
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>:$GITHUB_TOKEN@github.com/<user>/<repo>.git
env:
GITHUB_TOKEN: ${{ github.token }} # actions/checkout@v2がトークンをセットしてくれるので、これでpushできる
- name: deploy to ph-pages
run: yarn cd
working-directory: ./node
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