-
Notifications
You must be signed in to change notification settings - Fork 20
60 lines (54 loc) · 2.1 KB
/
Copy pathdeploy-Docker.yml
File metadata and controls
60 lines (54 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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
# 3. https://northflank.com/docs/v1/application/infrastructure-as-code/use-github-actions-with-northflank
# 4. https://github.com/northflank/deploy-to-northflank/issues/1#issuecomment-2629319799
name: Deploy Docker 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@v7
- name: Inject Environment variables
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
cat > .env.local <<EOF
${{ secrets.ENV_FILE }}
EOF
- uses: docker/login-action@v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/metadata-action@v6.1.0
id: meta
with:
images: ghcr.io/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=raw,value=latest
- uses: docker/build-push-action@v7.2.0
id: push
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: deploy to NorthFlank
env:
PROJECT_ID: ${{ secrets.NORTHFLANK_PROJECT_ID }}
SERVICE_ID: ${{ secrets.NORTHFLANK_SERVICE_ID }}
run: |
curl --fail-with-body --show-error --request POST \
--header "Authorization: Bearer ${{ secrets.NORTHFLANK_API_KEY }}" \
--header "Content-Type: application/json" \
--data '{"docker":{"configType":"default"},"external":{"credentials":"${{ secrets.NORTHFLANK_EXTERNAL_CREDENTIALS }}","imagePath":"ghcr.io/${{ env.IMAGE_NAME }}:latest"}}' \
https://api.northflank.com/v1/projects/$PROJECT_ID/services/$SERVICE_ID/deployment