Skip to content

Instantly share code, notes, and snippets.

@cgrotz
Last active September 20, 2023 21:40
Show Gist options
  • Save cgrotz/c7740deb1be66f9fcd38874eb512adfb to your computer and use it in GitHub Desktop.
Save cgrotz/c7740deb1be66f9fcd38874eb512adfb to your computer and use it in GitHub Desktop.
Example Github Action for deploying to Apigee X
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: proxy-ci
on:
push:
branches:
- 'main'
paths:
- '.github/workflows/ci.yaml'
- 'src/**'
jobs:
build:
name: "Deploy To Dev"
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v2
- id: auth
uses: google-github-actions/[email protected]
with:
token_format: "access_token"
create_credentials_file: true
activate_credentials_file: true
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_POOL_ID }}
service_account: ${{ secrets.SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
- name: Create API bundle
run: zip -r proxy.zip apiproxy
- name: Upload API Proxy Bundle
id: upload
run: "echo \"::set-output name=apigee-revision::$(curl --fail -X POST -H \"Content-Type: multipart/form-data\" -H \"Authorization: Bearer ${{steps.auth.outputs.access_token}}\" -F \"[email protected]\" \"https://apigee.googleapis.com/v1/organizations/${{secrets.APIGEE_ORG}}/apis?action=import&name=hello-world\" --silent | jq --raw-output .revision)\""
- name: Deploy Revision
run: "curl --fail -X POST -H \"Authorization: Bearer ${{steps.auth.outputs.access_token}}\" \"https://apigee.googleapis.com/v1/organizations/${{ secrets.APIGEE_ORG }}/environments/eval/apis/hello-world/revisions/${{steps.upload.outputs.apigee-revision}}/deployments?override=true\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment