chore: work save

This commit is contained in:
Marcel S. Henselin 2026-01-29 10:05:13 +01:00
parent 3e3f13d36d
commit 9752d63f7e
19 changed files with 1003 additions and 209 deletions

View file

@ -4,14 +4,31 @@ description: "Build pipeline"
inputs:
go-version:
description: "Go version to install"
default: '1.25'
required: true
golang-cilint-version:
description: "Golangci-lint version to install"
default: "2.7.2"
required: true
runs:
using: "composite"
steps:
- name: Install Go ${{ inputs.go-version }}
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: ${{ inputs.go-version }}
- name: Install project tools and dependencies
check-latest: true
go-version-file: 'go.mod'
# - name: Run golangci-lint
# uses: golangci/golangci-lint-action@v9
# with:
# version: ${{ inputs.golang-cilint-version }}
- name: Install needed tools
shell: bash
run: make project-tools
run: |
set -e
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${{ inputs.golang-cilint-version }}
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.24.0

View file

@ -13,7 +13,7 @@ env:
CODE_COVERAGE_ARTIFACT_NAME: "code-coverage"
jobs:
main:
prep:
name: prepare
runs-on: ubuntu-latest
permissions:
@ -22,6 +22,11 @@ jobs:
contents: read # Required to checkout repository.
pull-requests: write # Required to add PR comment.
steps:
- name: Install prerequisites
run: |
apt-get -qq -y update
apt-get -qq -y install unzip zip
- name: Checkout
uses: actions/checkout@v6
@ -46,15 +51,15 @@ jobs:
# - run: echo ${{ steps.plan.outputs.exitcode }}
# Run plan by default, or apply on merge.
- uses: op5dev/tf-via-pr@v13
with:
working-directory: path/to/directory
command: ${{ github.event_name == 'push' && 'apply' || 'plan' }}
arg-lock: ${{ github.event_name == 'push' }}
arg-backend-config: env/dev.tfbackend
arg-var-file: env/dev.tfvars
arg-workspace: dev-use1
plan-encrypt: ${{ secrets.PASSPHRASE }}
# - uses: op5dev/tf-via-pr@v13
# with:
# working-directory: path/to/directory
# command: ${{ github.event_name == 'push' && 'apply' || 'plan' }}
# arg-lock: ${{ github.event_name == 'push' }}
# arg-backend-config: env/dev.tfbackend
# arg-var-file: env/dev.tfvars
# arg-workspace: dev-use1
# plan-encrypt: ${{ secrets.PASSPHRASE }}
# - name: "Ensure docs are up-to-date"
# if: ${{ github.event_name == 'pull_request' }}
@ -65,15 +70,15 @@ jobs:
# if: ${{ github.event_name == 'pull_request' }}
# run: go mod tidy
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.7
args: --config=golang-ci.yaml --allow-parallel-runners --timeout=5m
# - name: golangci-lint
# uses: golangci/golangci-lint-action@v9
# with:
# version: v2.7
# args: --config=golang-ci.yaml --allow-parallel-runners --timeout=5m
# - name: Lint
# run: make lint
# - name: Test
# run: make test
@ -99,9 +104,9 @@ jobs:
code_coverage:
name: "Code coverage report"
if: github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch
if: github.event_name == 'pull_request' || (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
needs: main
needs: prep
permissions:
contents: read
actions: read # to download code coverage results from "main" job
@ -116,20 +121,87 @@ jobs:
root-package: 'tfregistry.sysops.stackit.rocks/mhenselin/stackitprivatepreview'
publish:
name: "Publish artifact"
name: "Publish provider"
# if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
actions: read # Required to identify workflow run.
checks: write # Required to add status summary.
contents: read # Required to checkout repository.
pull-requests: write # Required to add PR comment.
steps:
- name: Set up S3cmd cli tool
uses: s3-actions/s3cmd@v2.0.1
with:
provider: aws # default is linode
region: 'eu01'
access_key: ${{ secrets.S3_ACCESS_KEY }}
secret_key: ${{ secrets.S3_SECRET_KEY }}
- name: Interact with object storage
- name: Install needed tools
run: |
s3cmd ls
# s3cmd sync --recursive --acl-public dist s3://awesome.blog/
# s3cmd put dist/style.css --mime-type 'text/css' --acl-public s3://awesome.blog/style.css
s3cmd info s3://awesome.blog
apt-get -y -qq update
apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget
- name: Checkout
uses: actions/checkout@v6
- name: Install Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- name: Install go tools
run: |
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework@latest
go install github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest
- uses: actions/setup-java@v5
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'
- name: Run build pkg directory
run: |
go run cmd/main.go build
- name: Set up s3cfg
run: |
cat <<'EOF' >> ~/.s3cfg
[default]
host_base = https://object.storage.eu01.onstackit.cloud
host_bucket = https://%(bucket).object.storage.eu01.onstackit.cloud
check_ssl_certificate = False
access_key = ${{ secrets.S3_ACCESS_KEY }}
secret_key = ${{ secrets.S3_SECRET_KEY }}
EOF
- name: Import GPG key
run: |
gpg --import private.key
- name: Run GoReleaser
id: goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
uses: goreleaser/goreleaser-action@v6
with:
args: release --skip publish --clean --snapshot
- name: Prepare key file
run: |
echo $(echo ${{ secrets.KEY_FILE_B64 }} | base64 -d) >public_key.pem
- name: Prepare provider directory structure
run: |
VERSION=$(jq -c .version < dist/metadata.json)
go run main.go \
-ns=mhenselin \
-p=stackitprivatepreview \
-r=terraform-provider-stackitprivatepreview \
-d=tfregistry.sysops.stackit.rocks \
-gf=${{ secrets.GPG_FINGERPRINT }} \
-gk=public_key.pem \
-v=${VERSION}
- name: Publish provider to S3
run: |
set -e
cd release/
s3cmd put --recursive v1 s3://terraform-provider-privatepreview/
s3cmd put --recursive .well-known s3://terraform-provider-privatepreview/