зеркало из
1
0
Форкнуть 0

Add github action to update API files (#1464)

This commit is contained in:
James Burnside 2022-02-15 11:36:43 -08:00 коммит произвёл GitHub
Родитель db504039cb
Коммит 6d110d0597
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 78 добавлений и 0 удалений

78
.github/workflows/update-api-files.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,78 @@
name: Update API files
on:
workflow_dispatch:
jobs:
update_composite_snapshot:
name: Update all API files
runs-on: ubuntu-latest
strategy:
matrix:
include:
- flavor: 'beta'
- flavor: 'stable'
steps:
# Checkout repo
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Use a machine account when checking out. This is to workaround the issue were GitHub
# actions, when using the default account, cannot trigger other actions.
# This machine account is only for this PAT, pwd was created and thrown away
# If any update needed, create a new account, add access to the repo and generate a new PAT
token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
# Setup bot information for pushing new changes
# Here we use the id from the github actions bot: https://api.github.com/users/better-informatics%5Bbot%5D
- name: Setup bot git information
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
# If run from a PR, checkout PR branch and merge in latest changes from main branch
- name: Checkout PR branch and merge main
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
git checkout ${{ github.event.pull_request.head.ref }}
git merge origin/main
# Ensure node version is great enough
- name: Use Node.js v14.x
uses: actions/setup-node@v1
with:
node-version: '14.x'
# Try get node_modules from cache
- name: Restore node_modules from cache
uses: actions/cache@v2
with:
path: common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
# Install dependencies
- name: Install rush
run: npm install -g @microsoft/rush@5.47.0
- name: Install dependencies
run: rush install
# Switch flavor when necessary
- name: Switch flavor for stable build
if: ${{ matrix.flavor == 'stable' }}
run: rush switch-flavor:stable
- name: Build NPM Package
run: rush build -t @azure/communication-react
id: buildapifiles
- name: Check for API file changes
# If API files changed, they cause the build step to "fail" due to warnings
if: ${{ always() && steps.buildapifiles.outcome == 'failure' }}
id: changescheck
# Check if files have changed
# More information see: https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes
run: |
if [[ -z $(git status packages -s) ]]
then
echo "::set-output name=hasChanged::false"
else
echo "::set-output name=hasChanged::true"
fi
- name: Commit new snapshots
if: ${{ always() && steps.changescheck.outputs.hasChanged == 'true' }}
run: |
git add packages/**/*.api.md
git commit -m 'Update ${{ matrix.flavor }} API files'
git push