Build Docker Images #14
Workflow file for this run
  
    
      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: Build Docker Images | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| ghcr-build-pg: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: gcr.io/kaniko-project/executor:v1.23.0-debug | |
| options: --entrypoint /bin/sh | |
| permissions: | |
| packages: write | |
| steps: | |
| - name: Set branch name as environment variable | |
| run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
| - name: Set up Docker config for Kaniko | |
| run: | | |
| cat <<EOF > /kaniko/.docker/config.json | |
| { | |
| "auths": { | |
| "ghcr.io": { | |
| "auth": "$(echo -n "$GIT_USERNAME:$GIT_PASSWORD" | base64 -w0)" | |
| } | |
| } | |
| } | |
| EOF | |
| env: | |
| GIT_USERNAME: ${{ github.actor }} | |
| GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push pg | |
| run: | | |
| /kaniko/executor --dockerfile="Dockerfile" \ | |
| --context="${{ github.repositoryUrl }}#${{ github.ref_name }}#${{ github.sha }}" \ | |
| --destination="$GH_REGISTRY/$IMAGE_NAME:${GITHUB_REF_NAME}" \ | |
| env: | |
| GH_REGISTRY: "ghcr.io" | |
| IMAGE_NAME: "${{ github.repository }}/pg" | |
| delete-old-images: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Trigger Delete Old Image Workflow | |
| run: | | |
| curl -X POST \ | |
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| https://api.github.com/repos/${{ github.repository }}/actions/workflows/delete-old-image.yml/dispatches \ | |
| -d '{"ref": "main"}' | |
| deploy: | |
| needs: [delete-old-images, ghcr-build-pg] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to environment | |
| run: | | |
| echo "Deploying application" |