[APP-6858]: Add all RPC API definitions to AppService that will be required as part of the Self-Service FusionAuth epic. #1711
Workflow file for this run
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: Compile Protos | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
pull_request_target: | |
types: ['synchronize', 'labeled'] | |
branches: | |
- main | |
env: | |
# guards against running this action on its own previous commit | |
is-auto-commit: | |
commit-message: | |
commit-author: | |
GRPC_WEB_VERSION: '1.5.0' | |
jobs: | |
unlabel: | |
# This unlabel job runs on manual commits only. | |
# (because commits generated with GITHUB_TOKEN don't rerun workflow per https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow) | |
# note: this job doesn't need a 'safe to test' label because it doesn't check out code | |
runs-on: ubuntu-latest | |
steps: | |
- name: remove label | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_REPO: ${{ github.repository }} | |
run: gh pr edit ${{ github.event.pull_request.number }} --remove-label protos-compiled | |
compile-protos: | |
# run after unlabel so that ordering of remove-label, add-label is consistent | |
needs: unlabel | |
if: contains(github.event.pull_request.labels.*.name, 'safe to test') && contains(github.event.pull_request.labels.*.name, 'ready-for-protos') | |
runs-on: ubuntu-latest | |
env: | |
CI_COMMIT_MESSAGE_PREFIX: Built new protos from | |
CI_COMMIT_AUTHOR: github-actions | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
# note: check out fork because we will need it when we push below | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
- uses: actions/setup-node@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
# todo: cache download | |
- name: grpc-web | |
run: | | |
wget --quiet https://github.com/grpc/grpc-web/releases/download/${{ env.GRPC_WEB_VERSION }}/protoc-gen-grpc-web-${{ env.GRPC_WEB_VERSION }}-linux-x86_64 -O protoc-gen-grpc-web | |
chmod +x protoc-gen-grpc-web | |
sudo mv protoc-gen-grpc-web /usr/local/bin | |
which protoc-gen-grpc-web | |
- name: Set environment variables for previous commit | |
run: | | |
echo "commit-message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV | |
echo "commit-author=$(git log -1 --pretty=format:'%an')" >> $GITHUB_ENV | |
# If the last commit is an auto-generated commit from this workflow, we can exit early | |
- name: Set environment variable "is-auto-commit" | |
if: startsWith(env.commit-message, env.CI_COMMIT_MESSAGE_PREFIX) && env.commit-author == env.CI_COMMIT_AUTHOR | |
run: echo "is-auto-commit=true" >> $GITHUB_ENV | |
- uses: bufbuild/buf-setup-action@v1 | |
if: ${{ !env.is-auto-commit }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: arduino/setup-protoc@v1 | |
if: ${{ !env.is-auto-commit }} | |
- name: Compile protos | |
if: ${{ !env.is-auto-commit }} | |
run: make dist/buf | |
- name: commit + push | |
if: ${{ !env.is-auto-commit }} | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
git add . | |
git checkout -b ${{ github.event.pull_request.head.ref }} | |
git status | |
# magic email from https://github.com/orgs/community/discussions/26560 | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git config user.name github-actions | |
git commit -a -m "${{ env.CI_COMMIT_MESSAGE_PREFIX }} $(git rev-parse --short HEAD)" | |
git push -u origin ${{ github.event.pull_request.head.ref }} | |
else | |
echo "no changes, not creating an automatic commit" | |
fi | |
- name: add label | |
if: ${{ !env.is-auto-commit }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_REPO: ${{ github.repository }} | |
run: gh pr edit ${{ github.event.pull_request.number }} --add-label protos-compiled |