Skip to content

Deploy to Production environment #15

Deploy to Production environment

Deploy to Production environment #15

# reference:
# 1. https://github.com/docker/build-push-action/blob/master/docs/advanced/push-multi-registries.md
# 2. https://github.com/docker/build-push-action/blob/master/docs/advanced/share-image-jobs.md
name: Deploy to Production environment
on:
push:
tags:
- v*
jobs:
deploy_docker_image:
name: Deploy Docker image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v5
- name: Inject Environment variables
run: |
cat > .env.local <<EOF
${{ secrets.ENV_FILE }}
EOF
cp .env.local .env.personal.local
- uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/[email protected]
id: meta
with:
images: ghcr.io/${{ github.repository }}
- uses: docker/build-push-action@v6
id: push
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: deploy to NorthFlank
env:
PROJECT_ID: idea2app-service
SERVICE_ID: idea2app-web
run: |
curl --request POST \
--header "Authorization: Bearer ${{ secrets.NORTHFLANK_API_KEY }}" \
--header "Content-Type: application/json" \
--data '{"docker":{"configType":"default"},"external":{"credentials":"idea2app-github","imagePath":"ghcr.io/${{ github.repository }}:latest"}}' \
https://api.northflank.com/v1/projects/$PROJECT_ID/services/$SERVICE_ID/deployment