summaryrefslogtreecommitdiffstats
path: root/third_party/rust/jsparagus/.github/workflows/ci-generated.yml
blob: 4027c6c9c6fa803ff9f232755d17676c885cfc17 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Generate Files

on:
  push:
      branches:
      - master

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
    - name: Setup Python
      uses: actions/setup-python@v1
      with:
        python-version: "3.7"
    - name: Setup Git Profile
      run: |
        git config --local user.email "action@github.com"
        git config --local user.name "GitHub Action"
    - name: Revert Previous Change and Merge Master
      run: |
        if git ls-remote origin | grep refs/heads/ci_generated; then
          # If the remote branch exists.
          git fetch origin

          # Merge master, discarding changes in origin/ci_generated
          MASTER_REV=$(git log -1 master --pretty=%H)
          git checkout -b ci_generated-master origin/master
          git merge origin/ci_generated -m "Merge master ${MASTER_REV}" -s ours --allow-unrelated-histories
        else
          # Otherwise, just start from master branch.
          git checkout -b ci_generated-master
        fi
    - name: Generate Files
      run: |
        make init-venv && make all
        # OS independant replace
        sed -i.bak '/*_generated.rs/d' .gitignore && rm .gitignore.bak
    - name: Commit files
      run: |
        git add .
        MASTER_REV=$(git log -1 master --pretty=%H)
        git commit -m "Add Generated Files for ${MASTER_REV}" -a
    - name: Push changes
      uses: ad-m/github-push-action@master
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        branch: ci_generated