Add github action to run formatter for you (#1219)

This commit is contained in:
Timothee Guerin 2022-10-24 15:30:51 -07:00 коммит произвёл GitHub
Родитель 48d47ed217
Коммит 1420aa7c11
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 70 добавлений и 0 удалений

61
.github/workflows/format-pr.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,61 @@
name: Format
on:
issue_comment:
types: [created]
concurrency: ${{ github.workflow }}-${{ github.ref }}
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
# Create PR
pr_commented:
name: Format comment
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/cadleng format') }}
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Starting formatter! See progress [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})'
})
- name: Checkout
uses: actions/checkout@v3
- name: Checkout Pull Request
run: hub pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Use Node.js node 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install dependencies
run: npx @microsoft/rush update
- name: Build necessary packages
run: npx @microsoft/rush build --to @cadl-lang/prettier-plugin-cadl
- name: Format
run: npx @microsoft/rush format
- name: Commit
run: |
git config --global user.name 'Cadl Eng Bot'
git config --global user.email 'microsoft@users.noreply.github.com'
git commit -am "Format"
- name: Push
run: git push

Просмотреть файл

@ -292,6 +292,14 @@ As a contributor you can run the following command to trigger the build and crea
/azp run Cadl Pull Request Try It
```
## Run formatter
Trigger a workflow that will format the code, commit and push.
```
/cadleng format
```
# Cadl website
## Publish website to github.io

Просмотреть файл

@ -12,6 +12,7 @@ words:
- blockless
- cadl
- cadleditor
- cadleng
- Contoso
- CRUDL
- dogfood