Skip to content

Commit

Permalink
docs(gitlab): Add Gitlab CI Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
FalcoSuessgott committed Oct 24, 2023
1 parent 8a080a3 commit 755312f
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
8 changes: 8 additions & 0 deletions site/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,19 @@ curl -L -o tfx.exe "https://github.com/straubt1/tfx/releases/download/${version}
```

**Go Installation**

From Go version 1.19, the following is supported. `@latest` can be `@$VERSION`
```sh
go install github.com/straubt1/tfx@latest
```

**Container**

`tfx` is also packaged and published as a OCI Container Image in the Github Container Registry:
```sh
docker pull ghcr.io/straubt1/tfx:latest
```

<!-- ### Commands
* [`tfx workspace`](commands/workspace.md) - Commands to work with Workspaces
Expand Down
89 changes: 89 additions & 0 deletions site/docs/integrations/gitlab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Gitlab CI

## Module Release
The following snippet serves as a starting point to release Terraform Modules using `tfx`:

```yaml
# .gitlab-ci.yml
variables:
# tfx auth
TFE_HOSTNAME: ""
TFE_ORGANIZATION: ""
TFE_TOKEN: ""

# module vars
MODULE_NAME: aws-s3
MODULE_PROVIDER: aws

stages:
- release

terraform_module_release:
stage: release
image:
name: ghcr.io/straubt1/tfx:latest
entrypoint: [""]
script:
- tfx registry module show --name "${MODULE_NAME}" --provider "${MODULE_PROVIDER}" || tfx registry module create --name "${MODULE_NAME}" --provider "${MODULE_PROVIDER}"
- |
tfx registry module version create \
--name "${MODULE_NAME}" \
--provider "${MODULE_PROVIDER}" \
--version "${CI_COMMIT_TAG#v}" \
--directory "${CI_PROJECT_DIR}"
only:
- tags
```
## Provider Release
The following snippet serves as a starting point to release Terraform Provider using `tfx`:

```yaml
# .gitlab-ci.yml
variables:
# tfx auth
TFE_HOSTNAME: ""
TFE_ORGANIZATION: ""
TFE_TOKEN: ""
# goreleaser vars
GITLAB_TOKEN: ""
GPG_FINGERPRINT: ""
# provider vars
PROVIDER_NAME: custom-provider
stages:
- build
- release
# most likely you will call goreleaser before publishing
goreleaser:
stage: build
image:
name: goreleaser/goreleaser:latest
entrypoint: [""]
script:
- goreleaser release
artifacts:
paths:
- ${CI_PROJECT_DIR}/dist
rules:
- if: $CI_COMMIT_TAG
publish-provider:
stage: release
image:
name: ghcr.io/straubt1/tfx:latest
entrypoint: [""]
script:
- tfx registry provider show --name "${PROVIDER_NAME}" || tfx registry provider create --name "${PROVIDER_NAME}"
- |
tfx registry provider version create --name "${PROVIDER_NAME}" \
--version "${PROVIDER_VERSION}" \
--key-id "${GPG_FINGERPRINT}" \
--shasums="${CI_PROJECT_DIR}/dist/terraform-provider-${PROVIDER_NAME}_${CI_COMMIT_TAG#v}_SHA256SUMS" \
--shasums-sig="${CI_PROJECT_DIR}/dist/terraform-provider-${PROVIDER_NAME}_${CI_COMMIT_TAG#v}_SHA256SUMS.sig"
rules:
- if: $CI_COMMIT_TAG
```
2 changes: 2 additions & 0 deletions site/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ nav:
- Admin:
- GPG Keys: commands/admin_gpg.md
- Terraform Versions: commands/admin_terraformversion.md
- Integrations:
- Gitlab CI: integrations/gitlab.md
- About:
- Why TFx?: about/purpose.md
- Release Notes: about/release_notes.md
Expand Down

0 comments on commit 755312f

Please sign in to comment.