-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
81 lines (81 loc) · 2.49 KB
/
action.yml
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
name: 'build and push an image'
description: 'build an image and push it to the defined registry'
inputs:
composer:
description: 'install composer dependencies'
required: false
default: 'true'
composer-home:
description: 'composer root directory'
required: false
default: ${{ format('{0}/.composer', github.workspace) }}
composer-cache:
description: 'composer cache directory'
required: false
default: ${{ format('{0}/.composer/cache', github.workspace) }}
path:
description: 'image path relative to the registry'
required: true
pulumi:
description: 'pulumi config file path (YAML file relative to workspace directory)'
required: false
default: '.IaC/Pulumi.yaml'
username:
description: 'registry login'
required: true
password:
description: 'registry password'
required: true
runs:
using: "composite"
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: restore composer cache
uses: actions/cache@v4
if: inputs.composer == 'true'
with:
key: composer.cache.${{ hashFiles('composer.lock') }}
path: ${{ inputs.composer-cache }}
- name: install composer dependencies
run: composer install --no-progress --no-scripts --no-plugins --no-autoloader --no-dev -n --ignore-platform-reqs
shell: sh
if: inputs.composer == 'true'
env:
COMPOSER_HOME: ${{ inputs.composer-home }}
COMPOSER_CACHE_DIR: ${{ inputs.composer-cache }}
- name: get the registry host from the Pulumi config
id: host
uses: mikefarah/yq@v4
with:
cmd: yq '.config.image.value.host' ${{ inputs.pulumi }}
- name: get the registry path from the Pulumi config
id: path
uses: mikefarah/yq@v4
with:
cmd: yq '.config.image.value.path' ${{ inputs.pulumi }}
- name: login to the registry
uses: docker/login-action@v3
with:
registry: ${{ steps.host.outputs.result }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
- name: build and push the image
uses: docker/build-push-action@v6
with:
context: .
build-args: |
GIT_COMMIT=${{ github.sha }}
push: true
no-cache: true
pull: true
tags: ${{ format('{0}/{1}:{2}', steps.host.outputs.result, steps.path.outputs.result, github.sha) }}
- name: remove last build tag
run: git push origin :refs/tags/build
shell: sh
continue-on-error: true
- name: tag current build
run: |
git tag build
git push origin build
shell: sh