-
Notifications
You must be signed in to change notification settings - Fork 265
126 lines (119 loc) · 3.97 KB
/
Copy pathflow_docker.yml
File metadata and controls
126 lines (119 loc) · 3.97 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Build and Deploy Docker Image
on:
workflow_call:
inputs:
registry:
description: "The Docker Registry"
default: "ghcr.io"
required: false
type: string
image_name:
description: "The Docker image name"
default: ${{ github.repository }}
required: false
type: string
folder_name:
description: "The folder where the Dockerfile is located"
default: .
required: false
type: string
deploy_branch:
description: "The branch that will be deployed"
default: ${{ github.event.repository.default_branch }}
required: false
type: string
platforms:
description: "The platforms to build for"
required: false
type: string
default: linux/amd64
use_image_per_environment:
description: "Whether to create one image for each environment. Needed for statically generated webapps like NextJS"
default: false
required: false
type: boolean
jobs:
version:
name: Read Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Read version from VERSION file
id: version
working-directory: ${{ inputs.folder_name }}
run: |
VERSION=$(cat VERSION)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "## Version" >> $GITHUB_STEP_SUMMARY
echo "$VERSION" >> $GITHUB_STEP_SUMMARY
build:
name: Build Image
uses: ./.github/workflows/docker_build.yml
if: ${{ !inputs.use_image_per_environment }}
secrets: inherit
needs: version
with:
registry: ${{ inputs.registry }}
image_name: ${{ inputs.image_name }}
folder_name: ${{ inputs.folder_name }}
version: ${{ needs.version.outputs.version }}
run_number: ${{ github.run_number }}
user_name: ${{ github.actor }}
platforms: ${{ inputs.platforms }}
# Deploy to Development
deploy-dev:
name: Deploy Development Image
uses: ./.github/workflows/docker_deploy.yml
secrets: inherit
if: ${{ !failure() && !cancelled() && github.ref_name == inputs.deploy_branch }}
needs:
- version
- build
with:
version: ${{ needs.version.outputs.version }}
registry: ${{ inputs.registry }}
image_name: ${{ inputs.image_name }}
build_image: ${{ needs.build.outputs.build_image }}
build_image_tag: ${{ needs.build.outputs.build_image_tag }}
deploy_tag: ${{ needs.version.outputs.version }}-dev
platforms: ${{ inputs.platforms }}
environment: development
# Deploy to Staging
deploy-staging:
name: Deploy Staging Image
uses: ./.github/workflows/docker_deploy.yml
secrets: inherit
if: ${{ !failure() && !cancelled() && github.ref_name == inputs.deploy_branch }}
needs:
- version
- build
with:
version: ${{ needs.version.outputs.version }}
registry: ${{ inputs.registry }}
image_name: ${{ inputs.image_name }}
build_image: ${{ needs.build.outputs.build_image }}
build_image_tag: ${{ needs.build.outputs.build_image_tag }}
deploy_tag: ${{ needs.version.outputs.version }}-staging
environment: staging
platforms: ${{ inputs.platforms }}
# Deploy to Production
deploy-prod:
name: Deploy Production Image
uses: ./.github/workflows/docker_deploy.yml
secrets: inherit
if: ${{ !failure() && !cancelled() && github.ref_name == inputs.deploy_branch }}
needs:
- version
- build
with:
version: ${{ needs.version.outputs.version }}
registry: ${{ inputs.registry }}
image_name: ${{ inputs.image_name }}
build_image: ${{ needs.build.outputs.build_image }}
build_image_tag: ${{ needs.build.outputs.build_image_tag }}
deploy_tag: ${{ needs.version.outputs.version }}
environment: production
platforms: ${{ inputs.platforms }}