-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
164 lines (149 loc) · 4.65 KB
/
action.yml
File metadata and controls
164 lines (149 loc) · 4.65 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: 'RSpec'
description: 'Run RSpecs'
inputs:
registry:
description: 'Registry to get image'
required: false
default: ghcr.io
username:
description: 'Registry login username'
required: true
password:
description: 'Registry login password'
required: true
bundle_dockerfile_name:
description: 'dockerfile name, used in bundle build'
required: false
default: Dockerfile
main_dockerfile_name:
description: 'dockerfile name, used in main build'
required: false
default: Dockerfile
git_patoken:
description: 'git personal access token'
required: false
npm_patoken:
description: 'git personal access token for npms'
required: false
platforms:
description: 'platforms to build'
required: false
default: linux/amd64,linux/arm64
repo_owner:
description: 'Repo owner to push to'
required: false
default: codeboxxtechschool
push_dir:
description: 'directory to push to'
required: true
branch:
description: 'branch for tag'
required: true
version:
description: 'version for tag'
required: true
bundle_from:
description: 'bundle from this image'
required: true
do_bundle_step:
description: 'trigger bundle step'
default: true
required: false
do_main_step:
description: 'trigger main step'
default: true
required: false
main_stage:
description: 'stage to target in docker file'
required: false
build_args:
description: 'arguments to pass to main build'
required: false
# push_directory: cg/customer/test
# branch: ${{ steps.extract_branch.outputs.branch }}
# version: latest
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # OR "2"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ inputs.platforms }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
- name: "setup repo owner and tag leaf"
shell: bash
run: |
echo "REPO_OWNER=${{ inputs.registry }}/${{ inputs.repo_owner }}" >> $GITHUB_ENV
echo "TAG_LEAF=${{ inputs.branch }}:${{ inputs.version }}" >> $GITHUB_ENV
- name: "setup repo path"
shell: bash
run: echo "REPO_PATH=${{ env.REPO_OWNER }}/${{ inputs.push_dir }}" >> $GITHUB_ENV
- name: "setup bundle tag"
shell: bash
run: echo "BUNDLE_TAG=${{ env.REPO_PATH }}/bundle/${{ env.TAG_LEAF }}" >> $GITHUB_ENV
- name: Inspect already bundled manifest
id: tag_manifest
shell: bash
run: |
if docker manifest inspect ${{ env.BUNDLE_TAG }} >/dev/null; then
echo "docker_manifest_exists=true" >> $GITHUB_ENV
else
echo "docker_manifest_exists=false" >> $GITHUB_ENV
fi
- name: Get changed files
id: changed_files
if: env.docker_manifest_exists == 'true'
uses: tj-actions/changed-files@v32
with:
files: |
./*
client/*
./.github/**
- shell: bash
run: |
echo "do_bundle_step = ${{ inputs.do_bundle_step }}"
echo "tag_manifest exists = ${{ env.docker_manifest_exists }}"
echo "only_changed = ${{ steps.changed_files.outputs.any_changed }}"
- name: Build and push bundle
if: (inputs.do_bundle_step == 'true') && ((env.docker_manifest_exists == 'false') || (steps.changed_files.outputs.any_changed == 'true'))
uses: docker/build-push-action@v2
with:
secrets: |
GIT_PAT=${{ inputs.git_patoken }}
npm_pat=${{ inputs.npm_patoken }}
file: ${{ inputs.bundle_dockerfile_name }}
platforms: ${{ inputs.platforms }}
build-args: |
IMAGE_REF=${{ env.REPO_OWNER }}/${{ inputs.bundle_from }}
${{ inputs.build_args }}
push: true
tags: |
${{ env.BUNDLE_TAG }}
target: ${{ inputs.main_stage }}
- name: Build and push main
if: inputs.do_main_step == 'true'
uses: docker/build-push-action@v2
with:
secrets: |
GIT_PAT=${{ inputs.git_patoken }}
npm_pat=${{ inputs.npm_patoken }}
file: ${{ inputs.main_dockerfile_name }}
platforms: ${{ inputs.platforms }}
build-args: |
IMAGE_REF=${{ env.BUNDLE_TAG }}
${{ inputs.build_args }}
push: true
tags: |
${{ env.REPO_PATH }}/${{ env.TAG_LEAF }}
target: ${{ inputs.main_stage }}