fix(expressLoader): use correct property for status code (#579) #136
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: Publish Image | |
on: | |
push: | |
branches: [staging, main] | |
workflow_call: | |
inputs: | |
sha: | |
description: The commit SHA to run the workflow on | |
required: false | |
type: string | |
secrets: | |
sentry_auth_token: | |
description: The Sentry integration's token | |
required: true | |
workflow_dispatch: | |
env: | |
PROJECT_NAME: arora-api | |
jobs: | |
metadata: | |
name: Metadata | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.get_metadata.outputs.tag }} | |
build_args: ${{ steps.get_metadata.outputs.build_args }} | |
steps: | |
- name: Get metadata | |
id: get_metadata | |
env: | |
INPUT_SHA: ${{ inputs.sha }} | |
run: | | |
if [ "$GITHUB_REF_NAME" = 'main' ]; then | |
echo 'tag=latest' >> "$GITHUB_OUTPUT" | |
else | |
echo 'tag='"$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT" | |
fi | |
if [ "$GITHUB_REF_NAME" = 'staging' ] || [ "$GITHUB_REF_NAME" = 'main' ]; then | |
BUILD_ARGS='BUILD_HASH='${INPUT_SHA:-$GITHUB_SHA} | |
if [ "$GITHUB_REF_NAME" = 'main' ]; then | |
BUILD_ARGS+=$'\nNODE_ENV=production' | |
else | |
BUILD_ARGS+=$'\nNODE_ENV=staging' | |
fi | |
{ | |
echo 'build_args<<EOF' | |
echo "$BUILD_ARGS" | |
echo 'EOF' | |
} >> "$GITHUB_OUTPUT" | |
fi | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
needs: metadata | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
with: | |
ref: ${{ inputs.sha }} | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2.10.0 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 | |
with: | |
registry: ${{ vars.DOCKER_REGISTRY_URL }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image | |
id: build_push_image | |
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # v4.1.1 | |
with: | |
push: true | |
context: . | |
build-args: ${{ needs.metadata.outputs.build_args }} | |
cache-from: type=gha,scope=main | |
cache-to: type=gha,scope=main | |
tags: | | |
${{ vars.DOCKER_REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.PROJECT_NAME }}:${{ | |
needs.metadata.outputs.tag }} | |
- name: Get sourcemaps from image | |
if: ${{ !(github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image') }} | |
env: | |
IMAGE_NAME: ${{ fromJSON(steps.build_push_image.outputs.metadata)['image.name'] }} | |
run: | | |
docker cp "$(docker create "$IMAGE_NAME")":/opt/app/dist/. sourcemaps | |
- name: Create Sentry release | |
if: ${{ !(github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image') }} | |
uses: getsentry/action-release@4744f6a65149f441c5f396d5b0877307c0db52c7 # v1.4.1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ vars.SENTRY_ORG_NAME }} | |
SENTRY_PROJECT: ${{ env.PROJECT_NAME }} | |
with: | |
finalize: false | |
sourcemaps: sourcemaps | |
version: ${{ inputs.sha }} | |
url_prefix: ~/dist | |
update_check_run: | |
name: Update Check Run | |
runs-on: ubuntu-latest | |
needs: [metadata, publish] | |
if: github.event_name == 'workflow_dispatch' && github.workflow == 'Publish Image' && always() | |
steps: | |
- name: Get conclusion | |
id: get_conclusion | |
env: | |
RESULTS: ${{ join(needs.*.result, ' ') }} | |
run: | | |
echo 'conclusion=success' >> "$GITHUB_OUTPUT" | |
for RESULT in $RESULTS; do | |
if [ "$RESULT" = 'cancelled' ] || [ "$RESULT" = 'failure' ]; then | |
echo 'conclusion='"$RESULT" >> "$GITHUB_OUTPUT" | |
break | |
fi | |
done | |
- name: Update Publish Image check run | |
uses: guidojw/actions/update-check-run@870d7c8de5aeb08420bb88d8fbddb0222a9eac61 # v1.4.0 | |
with: | |
app_id: ${{ vars.GH_APP_ID }} | |
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
name: Publish Image | |
conclusion: ${{ steps.get_conclusion.outputs.conclusion }} | |
details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |