Skip to content

Merge pull request #64 from yebofresh/feature/fix-media-uploads #7

Merge pull request #64 from yebofresh/feature/fix-media-uploads

Merge pull request #64 from yebofresh/feature/fix-media-uploads #7

# This workflow will build a docker container, publish it to Google Container Registry.
name: Build and Deploy Saleor Production to GCR
on:
push:
branches:
- yebofresh/main
# Environment variables available to all jobs and steps in this workflow
env:
GCR_PROJECT: ${{ secrets.GCR_PROJECT }}
GS_JSON: ${{ secrets.GS_JSON_PRODUCTION }}
SALEOR_SECRET: ${{ secrets.SALEOR_PRODUCTION_BUILD_SECRET }}
GAC_FILENAME: gcs_production.json
GITHUB_SHA: ${{ github.sha }}
IMAGE: saleor-core-production
REGISTRY_HOSTNAME: eu.gcr.io
jobs:
setup-build-publish:
name: Setup, Build, Publish
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v3
# Google WIF Authentication
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
token_format: 'access_token'
workload_identity_provider: ${{ secrets.GCP_WIF_PROVIDER }}
service_account: ${{ secrets.GCP_WIF_SERVICE_ACCOUNT }}
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v1
# Login to Docker
- uses: 'docker/login-action@v1'
with:
registry: '${{ env.REGISTRY_HOSTNAME }}'
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
# Build the Docker image
- name: Build Core Django App
run: |
docker build -t "$REGISTRY_HOSTNAME"/"$GCR_PROJECT"/"$IMAGE":"$GITHUB_SHA" \
--build-arg GITHUB_SHA="$GITHUB_SHA" \
--build-arg GITHUB_REF="$GITHUB_REF" \
--build-arg GS_JSON_ARG="$GS_JSON" \
--build-arg GAC_FILE="$GAC_FILENAME" \
--build-arg SALEOR_SECRET_ARG="$SALEOR_SECRET" .
# Push the Docker image to Google Container Registry
- name: Publish Core Django App
run: |
docker push $REGISTRY_HOSTNAME/$GCR_PROJECT/"$IMAGE":$GITHUB_SHA
# Notify the #deploy channel on Discord of image creation or failure for deploys
- name: Push Notification to Discord
uses: sarisia/actions-status-discord@v1.8.6
if: ${{ success() }}
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "Saleor Production Image Created"
description: "A Docker image has been created and ready for deploy on Rancher.\n\nImage URL: `${{ env.REGISTRY_HOSTNAME }}/${{ env.GCR_PROJECT }}/${{ env.IMAGE }}:${{ env.GITHUB_SHA }}`"
- name: Push Failure Notification to Discord
uses: sarisia/actions-status-discord@v1.8.6
if: ${{ failure() }}
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "Saleor Production Image Creation"
description: "There was an error creating the Docker image"