From 4be7d1978a7dfd73044d5824f1f8acf2cba6fee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20S=C3=B6derberg?= Date: Thu, 19 Mar 2026 15:16:31 +0100 Subject: [PATCH] Moved to Gitlab --- .github/workflows/publish-template.yaml | 60 ------------------------- .gitlab-ci.yml | 28 ++++++++++++ 2 files changed, 28 insertions(+), 60 deletions(-) delete mode 100644 .github/workflows/publish-template.yaml create mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/publish-template.yaml b/.github/workflows/publish-template.yaml deleted file mode 100644 index 529f2da..0000000 --- a/.github/workflows/publish-template.yaml +++ /dev/null @@ -1,60 +0,0 @@ -name: Test and Publish Coder Template - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - test-and-publish: - runs-on: ubuntu-latest - env: - TEMPLATE_NAME: "LaTeX" - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Terraform - uses: hashicorp/setup-terraform@v2 - with: - terraform_version: latest - - - name: Set up Coder CLI - uses: coder/setup-action@v1 - with: - access_url: "https://coder.soderberg.tech" - coder_session_token: ${{ secrets.CODER_SESSION_TOKEN }} - - - name: Initilize Terraform - run: terraform init - - - name: Validate Terraform template - run: terraform validate - - - name: Get short commit SHA to use as template version name - id: name - run: echo "version_name=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" - - - name: Get latest commit title to use as template version description - id: message - run: - echo "pr_title=$(git log --format=%s -n 1 ${{ github.sha }})" >> - $GITHUB_OUTPUT - - - name: Push template to Coder - run: | - coder templates push $TEMPLATE_NAME -d $GITHUB_WORKSPACE --activate=false --name ${{ steps.name.outputs.version_name }} --message "${{ steps.message.outputs.pr_title }}" --yes - - - name: Create a test workspace - run: | - coder create -t $TEMPLATE_NAME --template-version ${{ steps.name.outputs.version_name }} test-${{ steps.name.outputs.version_name }} --yes --parameter "username=TEST-GIT-NAME,user_email=test@test.com" - - - name: Delete the test workspace - if: always() - run: coder delete test-${{ steps.name.outputs.version_name }} --yes - - - name: Promote template version - if: success() - run: | - coder template version promote --template=$TEMPLATE_NAME --template-version=${{ steps.name.outputs.version_name }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a707f71 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,28 @@ +stages: + - test-and-publish + +test-and-publish-template: + stage: test-and-publish + image: hashicorp/terraform:latest + + variables: + TEMPLATE_NAME: "LaTeX" + CODER_URL: "https://coder.soderberg.tech" + + rules: + - if: '$CI_COMMIT_BRANCH == "main"' + - if: '$CI_PIPELINE_SOURCE == "web"' + + before_script: + - apk add --no-cache curl + - curl -fsSL https://coder.com/install.sh | sh + + script: + - terraform init + - terraform validate + - coder templates push $TEMPLATE_NAME -d $CI_PROJECT_DIR --activate=false --name $CI_COMMIT_SHORT_SHA --message "$CI_COMMIT_TITLE" --yes + - coder create -t $TEMPLATE_NAME --template-version $CI_COMMIT_SHORT_SHA test-$CI_COMMIT_SHORT_SHA --yes --parameter "username=TEST-GIT-NAME,user_email=test@test.com" + - coder template version promote --template=$TEMPLATE_NAME --template-version=$CI_COMMIT_SHORT_SHA + + after_script: + - coder delete test-$CI_COMMIT_SHORT_SHA --yes || true