Merge pull request #844 from SierraSoftworks/dependabot/cargo/serde-1… #862
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: Deploy | |
on: | |
push: | |
branches: [ main ] | |
paths-ignore: | |
- "docs/**" | |
pull_request: | |
branches: [ main ] | |
permissions: | |
id-token: write | |
packages: write | |
env: | |
CARGO_TERM_COLOR: always | |
HANDLER_NAME: bender | |
IMAGE: sierrasoftworks/bender | |
GH_IMAGE: sierrasoftworks/bender | |
VERSION: dev | |
STAGING_DEPLOYMENT_APP_ID: 65d7542d-354d-4129-898c-8848be8d5ecd | |
STAGING_FUNCTION_NAME: bender-sierrasoftworks-staging | |
STAGING_HEALTHCHECK: "https://bender-staging.sierrasoftworks.com/api/v1/health" | |
LIVE_DEPLOYMENT_APP_ID: 5d3fdb10-30ca-4aaa-9128-17101a1ac349 | |
LIVE_FUNCTION_NAME: bender-sierrasoftworks | |
LIVE_HEALTHCHECK: "https://bender.sierrasoftworks.com/api/v1/health" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into registries | |
if: github.event_name == 'push' | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | |
echo "${{ secrets.DOCKER_HUB }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin | |
- name: Calculate version number | |
if: github.event_name == 'push' | |
run: | | |
IMAGE_ID=$(echo '${{ github.repository }}/${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]') | |
echo "GH_IMAGE=$IMAGE_ID" >> $GITHUB_ENV | |
VERSION=$(git describe --tags 2>/dev/null || git rev-parse --short HEAD) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Calculate version number | |
id: repo | |
run: | | |
IMA=$(git describe --tags 2>/dev/null || git rev-parse --short HEAD) | |
echo "::set-output name=version::$VERSION" | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
labels: org.opencontainers.image.authors=SierraSoftworks,org.opencontainers.image.version=${{ env.VERSION }},org.opencontainers.image.revision=${{ github.sha }} | |
tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ env.VERSION }},docker.pkg.github.com/${{ env.GH_IMAGE }}:latest,docker.pkg.github.com/${{ env.GH_IMAGE }}:${{ env.VERSION }} | |
- run: | | |
docker run --rm -t -v $PWD:/volume ${{ env.IMAGE }}:${{ env.VERSION }} cp /app/$HANDLER_NAME /volume/handler | |
mv ./handler ./$HANDLER_NAME | |
- name: Save handler artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.HANDLER_NAME }} | |
path: ${{ env.HANDLER_NAME }} | |
deploy-staging: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.actor != 'dependabot[bot]' | |
environment: | |
name: Staging | |
url: ${{ env.STAGING_HEALTHCHECK }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Fetch handler artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.HANDLER_NAME }} | |
- name: 'Login via Azure CLI' | |
uses: Azure/login@v2 | |
with: | |
tenant-id: a26571f1-22b3-4756-ac7b-39ca684fab48 | |
subscription-id: 108b3ddb-53fb-4344-80b2-d6c151912be6 | |
client-id: ${{ env.STAGING_DEPLOYMENT_APP_ID }} | |
- name: 'Run Azure Functions Action' | |
uses: Azure/functions-action@v1 | |
with: | |
app-name: ${{ env.STAGING_FUNCTION_NAME }} | |
respect-funcignore: 'true' | |
healthcheck-staging: | |
needs: deploy-staging | |
runs-on: ubuntu-latest | |
steps: | |
- name: Probe | |
uses: Jtalk/url-health-check-action@v4 | |
with: | |
url: ${{ env.STAGING_HEALTHCHECK }} | |
max-attempts: 5 | |
retry-delay: 10s | |
follow-redirect: true | |
deploy-live: | |
needs: healthcheck-staging | |
if: github.event_name == 'push' | |
environment: | |
name: Production | |
url: ${{ env.LIVE_HEALTHCHECK }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Fetch handler artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.HANDLER_NAME }} | |
- name: 'Login via Azure CLI' | |
uses: azure/login@v2 | |
with: | |
tenant-id: a26571f1-22b3-4756-ac7b-39ca684fab48 | |
subscription-id: 108b3ddb-53fb-4344-80b2-d6c151912be6 | |
client-id: ${{ env.LIVE_DEPLOYMENT_APP_ID }} | |
- name: 'Run Azure Functions Action' | |
uses: Azure/functions-action@v1 | |
with: | |
app-name: ${{ env.LIVE_FUNCTION_NAME }} | |
respect-funcignore: 'true' | |
healthcheck-live: | |
needs: deploy-live | |
runs-on: ubuntu-latest | |
steps: | |
- name: Probe | |
uses: Jtalk/url-health-check-action@v4 | |
with: | |
url: ${{ env.LIVE_HEALTHCHECK }} | |
max-attempts: 5 | |
retry-delay: 10s | |
follow-redirect: true |