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: Deploy to GitHub Pages (develop) | |
on: | |
push: | |
branches: | |
- develop | |
permissions: | |
contents: write | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' # プロジェクトに合わせてNode.jsのバージョンを指定 | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Install Dependencies | |
run: pnpm install # または npm install | |
- name: Build | |
run: npm run build # または pnpm run build | |
- name: Fetch and checkout gh-pages branch | |
run: | | |
git fetch origin gh-pages:gh-pages | |
git checkout gh-pages | |
- name: Configure Git | |
run: | | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
- name: (DEBUG) Show git status before changes | |
run: | | |
git status | |
git diff --staged | |
- name: Commit and push changes | |
run: | | |
mkdir -p dev | |
cp -r dist/* dev/ | |
git add dev | |
git diff --staged --quiet || git commit -m "Deploy develop branch to /dev directory" | |
git push origin gh-pages | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- name: (DEBUG) Show git status after changes | |
run: | | |
git status | |
git diff --staged |