Newer
Older
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
spec:
inputs:
# Job and Stage name
as:
default: 'module-release'
description: 'Defines the name of this job.'
stage:
default: 'release'
description: 'Defines the stage that this job will belong to.'
root_dir:
default: ${CI_PROJECT_DIR}
description: 'Root directory for the OpenTofu module.'
module_name:
default: ${CI_PROJECT_NAME}
description: |
Name of the module that should be published.
Must comply with the naming restrictions of the module registry.
module_system:
default: local
description: |
System that this module can be used with.
e.g. 'local' or 'azurerm'
module_version:
description: |
Version of the module that should be published.
e.g. '0.1.0'
default: ${CI_COMMIT_TAG}
---
'$[[ inputs.as ]]':
stage: $[[ inputs.stage ]]
image: curlimages/curl:8.8.0
variables:
TAR_FILENAME: /tmp/${CI_PROJECT_NAME}-${CI_COMMIT_SHA}.tgz
TF_ROOT: $[[ inputs.root_dir ]]
UPLOAD_URL:
${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/terraform/modules/$[[ inputs.module_name ]]/$[[ inputs.module_system ]]/$[[ inputs.module_version ]]/file
script:
- >-
tar -vczf "$TAR_FILENAME"
-C "$TF_ROOT"
--exclude=./.git
--exclude=./.terraform*
.
- >-
curl
--fail-with-body
--location
--header "JOB-TOKEN: ${CI_JOB_TOKEN}"
--upload-file "$TAR_FILENAME"
"$UPLOAD_URL"