-
Notifications
You must be signed in to change notification settings - Fork 33
Running the Registry Tool in GitHub Actions
Here is a GitHub Actions workflow that runs the registry
tool to apply an API description to a hosted instance of the Registry API.
To use it, store the file below in the .github/workflows
directory of your repository and replace apis/testapi
with the repo-local path to the YAML that you would like to apply. You can name the file anything with the .yaml
suffix, e.g. apply.yaml
.
This workflow requires a Google Cloud Service Account that is associated with the project containing your hosted API hub instance (the $GOOGLE_CLOUD_PROJECT
environment variable is set automatically). After creating the service account, create and download a JSON key and paste the contents of the downloaded key file into a GitHub repository secret. This action assumes that the secret is named REPOSITORY_ACTIONS
.
name: Run the registry tool
on:
schedule:
- cron: '0 0 * * *' # each 12:00 UTC
push:
branches: [ main ]
tags: [ 'v*.*.*' ] # semver release
pull_request:
branches: [ main ]
jobs:
registry-apply:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.REGISTRY_ACTIONS }}'
- name: Set up the Google Cloud SDK
uses: 'google-github-actions/setup-gcloud@v1'
- name: Verify the Google Cloud SDK installation
run: 'gcloud info'
- name: Get the registry tool
run: |
curl -L https://raw.githubusercontent.com/apigee/registry/main/downloadLatest.sh | sh -
echo "$HOME/.registry/bin" >> $GITHUB_PATH
- name: Configure the registry tool
run: |
registry config configurations create hosted
registry config set address apigeeregistry.googleapis.com:443
registry config set token-source 'gcloud auth print-access-token'
registry config set location global
registry config set project $GOOGLE_CLOUD_PROJECT
- name: Run a query
run: "registry get artifacts"
- name: Apply an API description from the `apis/testapi` directory of this repository.
run: "registry apply -f apis/testapi -R"