-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
102 lines (93 loc) · 3.47 KB
/
action.yaml
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
name: "push-to-niployments"
description: |
Push a versioned image, built from this project, to NIployments' Image Registry
inputs:
project_name:
description: |
The name of the project under which to store the generated image artifact.
required: false
default: niaefeup
repository_name:
description: |
The name of the repository, stored under "project_name", to which the new image artifact should be pushed
required: false
docker_dockerfile:
description: |
The name of the Dockerfile used to build this image.
required: false
default: "Dockerfile-prod"
docker_context:
description: |
The path to the directory containing the Dockerfile used to build the project.
required: false
docker_target:
description: |
Sets the target stage to build
required: false
docker_build_args:
description: |
List of build-time variables
required: false
# Due to limitations in composite runners, this is, in my opinion, the best way to do this.
# See https://github.com/orgs/community/discussions/49689 for more details.
# TLDR: apparently the 'vars' and the 'secrets' contexts are not available to composite runners.
NIPLOYMENTS_REGISTRY_URL:
description: |
The URL of the NIployments' Image Registry
required: true
NIPLOYMENTS_REGISTRY_USERNAME:
description: |
The username used to authenticate with the NIployments' Image Registry
required: true
NIPLOYMENTS_REGISTRY_PASSWORD:
description: |
The password used to authenticate with the NIployments' Image Registry
required: true
runs:
using: "composite"
steps:
- name: "Parse repository name"
id: "name-parsing"
run: ${{ github.action_path }}/scripts/get-repository-name.sh
shell: bash
env:
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
INPUT_REPOSITORY_NAME: ${{ inputs.repository_name }}
- name: Login to NIployments registry
uses: docker/login-action@v1
with:
# These are the values of the Dev cluster.
registry: ${{ inputs.NIPLOYMENTS_REGISTRY_URL }}
username: ${{ inputs.NIPLOYMENTS_REGISTRY_USERNAME }}
password: ${{ inputs.NIPLOYMENTS_REGISTRY_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout
uses: actions/checkout@v4
- name: Generate new tag for project image
id: tag
uses: docker/metadata-action@v5
with:
images: ${{ inputs.NIPLOYMENTS_REGISTRY_URL }}/${{ inputs.project_name }}/${{ steps.name-parsing.outputs.REPOSITORY_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: "Parse Docker context and Dockerfile"
id: "docker-parsing"
run: ${{ github.action_path }}/scripts/parse-docker-context-and-dockerfile.sh
shell: bash
env:
INPUT_DOCKER_CONTEXT: ${{ inputs.docker_context }}
INPUT_DOCKER_DOCKERFILE: ${{ inputs.docker_dockerfile }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
context: ${{ steps.docker-parsing.outputs.DOCKER_CONTEXT }}
file: ${{ steps.docker-parsing.outputs.DOCKER_DOCKERFILE }}
tags: ${{ steps.tag.outputs.tags }}
labels: ${{ steps.tag.outputs.labels }}
target: ${{ inputs.docker_target }}
build-args: ${{ inputs.docker_build_args }}