GitHub Actions, ビルド結果を別ブランチにpushする

GitHub Actions実行中に生成したbuildディレクトリの内容を別ブランチにpushする。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Build
on:
  push:
    branches:
      - master

jobs:
  deploy:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Setup Python
      uses: actions/setup-python@v2
      with:
        # Version range or exact version of a Python version to use, using SemVer's version range syntax.
        python-version: 3.x

    - name: Install dependencies
      run: pip3 install -r requirements.txt

    - name: Build
      run: python3 app/main.py
      # run: |
      #   python3 app/cmd1.py
      #   python3 app/cmd2.py

    # https://github.com/s0/git-publish-subdir-action
    - name: Push to build branch
      uses: s0/git-publish-subdir-action@master
      env:
        REPO: self
        BRANCH: build
        FOLDER: build
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}