Fix CI by also login in with AzCLI (#193) #191
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: Planetary Computer APIs CI/CD | |
on: | |
push: | |
branches: [main] | |
tags: ["*"] | |
jobs: | |
build_and_publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Run cibuild | |
run: ./scripts/cibuild | |
- name: Get image tag | |
id: get_image_tag | |
run: | |
case "${GITHUB_REF}" in | |
*tags*) | |
echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT | |
;; | |
*) | |
echo "tag=latest" >> $GITHUB_OUTPUT | |
;; | |
esac | |
- name: Log into the ACR | |
env: | |
CLIENT_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).clientId }} | |
CLIENT_SECRET: ${{ fromJSON(secrets.AZURE_CREDENTIALS).clientSecret }} | |
run: | |
docker login pcccr.azurecr.io --username ${CLIENT_ID} --password ${CLIENT_SECRET} | |
az acr login --name pcccr --username ${CLIENT_ID} --password ${CLIENT_SECRET} | |
- name: Publish images | |
run: ./scripts/cipublish --acr pcccr --tag ${{steps.get_image_tag.outputs.tag}} | |
outputs: | |
image_tag: ${{ steps.get_image_tag.outputs.tag }} | |
deploy: | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: | |
- build_and_publish | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get image tag | |
id: get_image_tag | |
if: ${{ github.base_ref }} | |
run: | |
case "${GITHUB_REF}" in | |
*tags*) | |
echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT | |
;; | |
*) | |
echo "tag=latest" >> $GITHUB_OUTPUT | |
;; | |
esac | |
- name: Deploy | |
run: ./scripts/cideploy | |
env: | |
IMAGE_TAG: ${{needs.build_and_publish.outputs.image_tag}} | |
ENVIRONMENT: staging | |
ARM_CLIENT_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).clientId }} | |
ARM_CLIENT_SECRET: ${{ fromJSON(secrets.AZURE_CREDENTIALS).clientSecret }} | |
ARM_SUBSCRIPTION_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).subscriptionId }} | |
ARM_TENANT_ID: ${{ fromJSON(secrets.AZURE_CREDENTIALS).tenantId }} |