chore: Add tofu workflows (#1)
Reviewed-on: #1 Co-authored-by: pgijsbertsen <117165507+pgijsbertsen@users.noreply.github.com> Co-committed-by: pgijsbertsen <117165507+pgijsbertsen@users.noreply.github.com>
This commit is contained in:
parent
554f67513f
commit
b095cdd0e7
4 changed files with 430 additions and 0 deletions
109
.forgejo/workflows/tofu-apply-k8s-wheatley.yaml
Normal file
109
.forgejo/workflows/tofu-apply-k8s-wheatley.yaml
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
---
|
||||
name: Tofu Apply k8s-wheatley
|
||||
on:
|
||||
workflow_call:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- pve01.wheatley.in/k8s-wheatley/**
|
||||
|
||||
jobs:
|
||||
tofu-apply-k8s-wheatley:
|
||||
runs-on: docker
|
||||
defaults:
|
||||
run:
|
||||
working-directory: pve01.wheatley.in/k8s-wheatley
|
||||
permissions:
|
||||
pull-requests: write
|
||||
env:
|
||||
AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
TF_VAR_proxmox_endpoint: ${{ secrets.PROXMOX_ENDPOINT }}
|
||||
TF_VAR_proxmox_api_token: ${{ secrets.PROXMOX_API_TOKEN }}
|
||||
PR_NUMBER: ${{ forge.event.pull_request.number }}
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
- uses: https://github.com/opentofu/setup-opentofu@v1
|
||||
with:
|
||||
tofu_version: 1.11.5
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
apt update
|
||||
apt install -y jq
|
||||
|
||||
- name: OpenTofu Init
|
||||
id: init
|
||||
run: tofu init --upgrade
|
||||
|
||||
- name: OpenTofu Format
|
||||
id: fmt
|
||||
run: tofu fmt -check
|
||||
|
||||
- name: OpenTofu Validate
|
||||
id: validate
|
||||
run: tofu validate -no-color
|
||||
|
||||
- name: OpenTofu Plan
|
||||
id: plan
|
||||
run: tofu plan -no-color
|
||||
continue-on-error: true
|
||||
|
||||
- name: OpenTofu Apply
|
||||
id: apply
|
||||
run: tofu apply -auto-approve -no-color
|
||||
continue-on-error: true
|
||||
|
||||
- name: Add comment
|
||||
id: comment
|
||||
if: always()
|
||||
env:
|
||||
COMMENT_BODY: |
|
||||
### ${{forge.workflow}}
|
||||
#### ${{ steps.fmt.outcome == 'success' && '✅' || '❌' }} OpenTofu Format and Style 🖌
|
||||
#### ${{ steps.init.outcome == 'success' && '✅' || '❌' }} OpenTofu Initialization ⚙️
|
||||
#### ${{ steps.validate.outcome == 'success' && '✅' || '❌' }} OpenTofu Validation 🤖
|
||||
<details><summary>Validation Output</summary>
|
||||
|
||||
```
|
||||
${{ steps.validate.outputs.stdout }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### ${{ steps.apply.outcome == 'success' && '✅' || '❌' }} OpenTofu Apply 🚀
|
||||
|
||||
<details><summary>Show Apply</summary>
|
||||
|
||||
```
|
||||
${{ steps.apply.outputs.stdout }}
|
||||
```
|
||||
|
||||
</details>
|
||||
run: |
|
||||
payload=$(jq -Rs --arg body "$COMMENT_BODY" '{body: $body}' <<< "$COMMENT_BODY")
|
||||
|
||||
existing_comment=$(curl -s \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments")
|
||||
comment_id=$(echo "$existing_comment" | jq -r \
|
||||
'.[] | select(.body | test("${{ forge.workflow }}")) | .id' | head -n 1)
|
||||
|
||||
|
||||
if [ -n "${comment_id}" ] && [ "${comment_id}" != "null" ]; then
|
||||
echo "Found comment with id ${comment_id}, updating..." && \
|
||||
curl -s -X PATCH \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/comments/${comment_id}" \
|
||||
-d "$payload"
|
||||
else
|
||||
echo "Creating new comment..." && \
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments" \
|
||||
-d "$payload"
|
||||
fi
|
||||
109
.forgejo/workflows/tofu-apply-templates.yaml
Normal file
109
.forgejo/workflows/tofu-apply-templates.yaml
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
---
|
||||
name: Tofu Apply pve01.wheatley.in templates
|
||||
on:
|
||||
workflow_call:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- pve01.wheatley.in/templates/**
|
||||
|
||||
jobs:
|
||||
tofu-apply-templates:
|
||||
runs-on: docker
|
||||
defaults:
|
||||
run:
|
||||
working-directory: pve01.wheatley.in/templates
|
||||
permissions:
|
||||
pull-requests: write
|
||||
env:
|
||||
AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
TF_VAR_proxmox_endpoint: ${{ secrets.PROXMOX_ENDPOINT }}
|
||||
TF_VAR_proxmox_api_token: ${{ secrets.PROXMOX_API_TOKEN }}
|
||||
PR_NUMBER: ${{ forge.event.pull_request.number }}
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
- uses: https://github.com/opentofu/setup-opentofu@v1
|
||||
with:
|
||||
tofu_version: 1.11.5
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
apt update
|
||||
apt install -y jq
|
||||
|
||||
- name: OpenTofu Init
|
||||
id: init
|
||||
run: tofu init --upgrade
|
||||
|
||||
- name: OpenTofu Format
|
||||
id: fmt
|
||||
run: tofu fmt -check
|
||||
|
||||
- name: OpenTofu Validate
|
||||
id: validate
|
||||
run: tofu validate -no-color
|
||||
|
||||
- name: OpenTofu Plan
|
||||
id: plan
|
||||
run: tofu plan -no-color
|
||||
continue-on-error: true
|
||||
|
||||
- name: OpenTofu Apply
|
||||
id: apply
|
||||
run: tofu apply -auto-approve -no-color
|
||||
continue-on-error: true
|
||||
|
||||
- name: Add comment
|
||||
id: comment
|
||||
if: always()
|
||||
env:
|
||||
COMMENT_BODY: |
|
||||
### ${{forge.workflow}}
|
||||
#### ${{ steps.fmt.outcome == 'success' && '✅' || '❌' }} OpenTofu Format and Style 🖌
|
||||
#### ${{ steps.init.outcome == 'success' && '✅' || '❌' }} OpenTofu Initialization ⚙️
|
||||
#### ${{ steps.validate.outcome == 'success' && '✅' || '❌' }} OpenTofu Validation 🤖
|
||||
<details><summary>Validation Output</summary>
|
||||
|
||||
```
|
||||
${{ steps.validate.outputs.stdout }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### ${{ steps.apply.outcome == 'success' && '✅' || '❌' }} OpenTofu Apply 🚀
|
||||
|
||||
<details><summary>Show Apply</summary>
|
||||
|
||||
```
|
||||
${{ steps.apply.outputs.stdout }}
|
||||
```
|
||||
|
||||
</details>
|
||||
run: |
|
||||
payload=$(jq -Rs --arg body "$COMMENT_BODY" '{body: $body}' <<< "$COMMENT_BODY")
|
||||
|
||||
existing_comment=$(curl -s \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments")
|
||||
comment_id=$(echo "$existing_comment" | jq -r \
|
||||
'.[] | select(.body | test("${{ forge.workflow }}")) | .id' | head -n 1)
|
||||
|
||||
|
||||
if [ -n "${comment_id}" ] && [ "${comment_id}" != "null" ]; then
|
||||
echo "Found comment with id ${comment_id}, updating..." && \
|
||||
curl -s -X PATCH \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/comments/${comment_id}" \
|
||||
-d "$payload"
|
||||
else
|
||||
echo "Creating new comment..." && \
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments" \
|
||||
-d "$payload"
|
||||
fi
|
||||
106
.forgejo/workflows/tofu-plan-k8s-wheatley.yaml
Normal file
106
.forgejo/workflows/tofu-plan-k8s-wheatley.yaml
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
---
|
||||
name: Tofu Plan k8s-wheatley
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- pve01.wheatley.in/k8s-wheatley/**
|
||||
- .forgejo/workflows/tofu-plan-k8s-wheatley.yaml
|
||||
|
||||
jobs:
|
||||
tofu-plan-k8s-wheatley:
|
||||
runs-on: docker
|
||||
defaults:
|
||||
run:
|
||||
working-directory: pve01.wheatley.in/k8s-wheatley
|
||||
permissions:
|
||||
pull-requests: write
|
||||
env:
|
||||
AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
TF_VAR_proxmox_endpoint: ${{ secrets.PROXMOX_ENDPOINT }}
|
||||
TF_VAR_proxmox_api_token: ${{ secrets.PROXMOX_API_TOKEN }}
|
||||
PR_NUMBER: ${{ forge.event.pull_request.number }}
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
- uses: https://github.com/opentofu/setup-opentofu@v1
|
||||
with:
|
||||
tofu_version: 1.11.5
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
apt update
|
||||
apt install -y jq
|
||||
|
||||
- name: OpenTofu Init
|
||||
id: init
|
||||
run: tofu init --upgrade
|
||||
|
||||
- name: OpenTofu Format
|
||||
id: fmt
|
||||
run: tofu fmt -check
|
||||
|
||||
- name: OpenTofu Validate
|
||||
id: validate
|
||||
run: tofu validate -no-color
|
||||
|
||||
- name: OpenTofu Plan
|
||||
id: plan
|
||||
run: tofu plan -no-color
|
||||
continue-on-error: true
|
||||
|
||||
- name: Add comment
|
||||
id: comment
|
||||
if: always()
|
||||
env:
|
||||
COMMENT_BODY: |
|
||||
### ${{forge.workflow}}
|
||||
#### ${{ steps.fmt.outcome == 'success' && '✅' || '❌' }} OpenTofu Format and Style 🖌
|
||||
#### ${{ steps.init.outcome == 'success' && '✅' || '❌' }} OpenTofu Initialization ⚙️
|
||||
#### ${{ steps.validate.outcome == 'success' && '✅' || '❌' }} OpenTofu Validation 🤖
|
||||
<details><summary>Validation Output</summary>
|
||||
|
||||
```
|
||||
${{ steps.validate.outputs.stdout }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### ${{ steps.plan.outcome == 'success' && '✅' || '❌' }} OpenTofu Plan 📖
|
||||
|
||||
<details><summary>Show Plan</summary>
|
||||
|
||||
```
|
||||
${{ steps.plan.outputs.stdout }}
|
||||
```
|
||||
|
||||
</details>
|
||||
run: |
|
||||
payload=$(jq -Rs --arg body "$COMMENT_BODY" '{body: $body}' <<< "$COMMENT_BODY")
|
||||
|
||||
existing_comment=$(curl -s \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments")
|
||||
comment_id=$(echo "$existing_comment" | jq -r \
|
||||
'.[] | select(.body | test("${{ forge.workflow }}")) | .id' | head -n 1)
|
||||
|
||||
|
||||
if [ -n "${comment_id}" ] && [ "${comment_id}" != "null" ]; then
|
||||
echo "Found comment with id ${comment_id}, updating..." && \
|
||||
curl -s -X PATCH \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/comments/${comment_id}" \
|
||||
-d "$payload"
|
||||
else
|
||||
echo "Creating new comment..." && \
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments" \
|
||||
-d "$payload"
|
||||
fi
|
||||
106
.forgejo/workflows/tofu-plan-templates.yaml
Normal file
106
.forgejo/workflows/tofu-plan-templates.yaml
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
---
|
||||
name: Tofu Plan pve01.wheatley.in templates
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- pve01.wheatley.in/templates/**
|
||||
- .forgejo/workflows/tofu-plan-templates.yaml
|
||||
|
||||
jobs:
|
||||
tofu-plan-templates:
|
||||
runs-on: docker
|
||||
defaults:
|
||||
run:
|
||||
working-directory: pve01.wheatley.in/templates
|
||||
permissions:
|
||||
pull-requests: write
|
||||
env:
|
||||
AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
TF_VAR_proxmox_endpoint: ${{ secrets.PROXMOX_ENDPOINT }}
|
||||
TF_VAR_proxmox_api_token: ${{ secrets.PROXMOX_API_TOKEN }}
|
||||
PR_NUMBER: ${{ forge.event.pull_request.number }}
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
- uses: https://github.com/opentofu/setup-opentofu@v1
|
||||
with:
|
||||
tofu_version: 1.11.5
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
apt update
|
||||
apt install -y jq
|
||||
|
||||
- name: OpenTofu Init
|
||||
id: init
|
||||
run: tofu init --upgrade
|
||||
|
||||
- name: OpenTofu Format
|
||||
id: fmt
|
||||
run: tofu fmt -check
|
||||
|
||||
- name: OpenTofu Validate
|
||||
id: validate
|
||||
run: tofu validate -no-color
|
||||
|
||||
- name: OpenTofu Plan
|
||||
id: plan
|
||||
run: tofu plan -no-color
|
||||
continue-on-error: true
|
||||
|
||||
- name: Add comment
|
||||
id: comment
|
||||
if: always()
|
||||
env:
|
||||
COMMENT_BODY: |
|
||||
### ${{forge.workflow}}
|
||||
#### ${{ steps.fmt.outcome == 'success' && '✅' || '❌' }} OpenTofu Format and Style 🖌
|
||||
#### ${{ steps.init.outcome == 'success' && '✅' || '❌' }} OpenTofu Initialization ⚙️
|
||||
#### ${{ steps.validate.outcome == 'success' && '✅' || '❌' }} OpenTofu Validation 🤖
|
||||
<details><summary>Validation Output</summary>
|
||||
|
||||
```
|
||||
${{ steps.validate.outputs.stdout }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### ${{ steps.plan.outcome == 'success' && '✅' || '❌' }} OpenTofu Plan 📖
|
||||
|
||||
<details><summary>Show Plan</summary>
|
||||
|
||||
```
|
||||
${{ steps.plan.outputs.stdout }}
|
||||
```
|
||||
|
||||
</details>
|
||||
run: |
|
||||
payload=$(jq -Rs --arg body "$COMMENT_BODY" '{body: $body}' <<< "$COMMENT_BODY")
|
||||
|
||||
existing_comment=$(curl -s \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments")
|
||||
comment_id=$(echo "$existing_comment" | jq -r \
|
||||
'.[] | select(.body | test("${{ forge.workflow }}")) | .id' | head -n 1)
|
||||
|
||||
|
||||
if [ -n "${comment_id}" ] && [ "${comment_id}" != "null" ]; then
|
||||
echo "Found comment with id ${comment_id}, updating..." && \
|
||||
curl -s -X PATCH \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/comments/${comment_id}" \
|
||||
-d "$payload"
|
||||
else
|
||||
echo "Creating new comment..." && \
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ forge.api_url }}/repos/${{ forge.repository }}/issues/$PR_NUMBER/comments" \
|
||||
-d "$payload"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue