Bump flask from 3.0.2 to 3.1.3 (#22) #17
This file contains hidden or 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 Docker image to GHCR and Google Artifact Registry | |
| on: | |
| push: | |
| branches: | |
| - main # Or master, or your default branch | |
| jobs: | |
| build_and_publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write # Required to publish packages to GHCR | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: sntxrr/titlecreator | |
| - name: Install yq | |
| run: | | |
| wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
| chmod +x /usr/local/bin/yq | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v1 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Configure Docker for Artifact Registry | |
| run: gcloud auth configure-docker us-west2-docker.pkg.dev --quiet | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v4 | |
| with: | |
| images: | | |
| ghcr.io/sntxrr/titlecreator | |
| us-west2-docker.pkg.dev/title-gen/titlegenerator/titlecreator | |
| tags: | | |
| type=raw,value=latest | |
| type=sha,format=short | |
| - name: Build and push Docker image | |
| id: build-push | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Get image SHA | |
| id: get-sha | |
| run: | | |
| # Get the SHA of the image we just pushed | |
| IMAGE_SHA=$(docker inspect us-west2-docker.pkg.dev/title-gen/titlegenerator/titlecreator:latest --format='{{.RepoDigests}}' | cut -d'@' -f2) | |
| # Store just the SHA part without the image name | |
| IMAGE_SHA_ONLY=$(echo "$IMAGE_SHA" | cut -d' ' -f1) | |
| echo "IMAGE_SHA_ONLY=$IMAGE_SHA_ONLY" >> $GITHUB_ENV | |
| echo "Found image SHA: $IMAGE_SHA_ONLY" | |
| - name: Update cloudrun.yaml with image SHA | |
| run: | | |
| # Create a temporary file | |
| cp cloudrun.yaml cloudrun.yaml.tmp | |
| # Use yq to update the image field while preserving YAML structure | |
| yq e ".spec.template.spec.containers[0].image = \"us-west2-docker.pkg.dev/title-gen/titlegenerator/titlecreator@${{ env.IMAGE_SHA_ONLY }}\"" cloudrun.yaml.tmp > cloudrun.yaml | |
| rm cloudrun.yaml.tmp | |
| echo "Updated cloudrun.yaml with image SHA" | |
| - name: Deploy to Cloud Run | |
| run: | | |
| gcloud run services replace cloudrun.yaml \ | |
| --region=us-west1 \ | |
| --project=title-gen |