Spec Update #101
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: Spec Update | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: [spec_update] | |
jobs: | |
Update: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2.7.0 | |
- name: Setup Python environment | |
uses: actions/setup-python@v3.1.4 | |
with: | |
python-version: 3.7 | |
- name: Get current time | |
uses: 1466587594/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY_MM_DD | |
utcOffset: "-08:00" | |
- name: Update Modules | |
run: | | |
git submodule init | |
git submodule update --remote --recursive | |
- name: Generate Branch Name | |
id: git-branch | |
run: | | |
echo "::set-output name=branch::spec_update_${{ steps.current-time.outputs.formattedTime }}" | |
- name: Generate Num Diffs | |
id: git-diff-num | |
run: | | |
diffs=$(git diff --submodule spec | grep ">" | wc -l) | |
echo "Number of Spec diffs: $diffs" | |
echo "::set-output name=num-diff::$diffs" | |
- name: Generate Diff | |
id: git-diff | |
run: | | |
cd spec | |
gitdiff=$(git log -n ${{ steps.git-diff-num.outputs.num-diff }} --pretty="format:%n %H %n%n %b") | |
commit="Automated Spec Update $gitdiff" | |
commit="${commit//'%'/'%25'}" | |
commit="${commit//$'\n'/'%0A'}" | |
commit="${commit//$'\r'/'%0D'}" | |
echo "Commit Message: $commit" | |
echo "::set-output name=commit::$commit" | |
cd .. | |
- name: Generate New Routes | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
python generate_base_client.py | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5.0.3 | |
if: steps.git-diff-num.outputs.num-diff != 0 | |
with: | |
commit-message: | | |
${{ steps.git-diff.outputs.commit}} | |
branch: ${{ steps.git-branch.outputs.branch }} | |
delete-branch: true | |
title: 'Automated Spec Update' | |
body: | | |
${{ steps.git-diff.outputs.commit}} | |
base: 'main' | |
# TODO: `SPEC_UPDATE_TOKEN` needs to be fixed | |
# team-reviewers: "@dropbox/sdk-maintainers" | |
draft: false |