Changing comment action.
This commit is contained in:
@@ -7,7 +7,8 @@ on:
|
|||||||
- "main"
|
- "main"
|
||||||
- "renovate/**"
|
- "renovate/**"
|
||||||
paths:
|
paths:
|
||||||
- "cloudflare/**"
|
- "cloudflare/**"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
OPENTOFU_VERSION: "1.10.6"
|
OPENTOFU_VERSION: "1.10.6"
|
||||||
HC_VAULT_VERSION: "1.20.4"
|
HC_VAULT_VERSION: "1.20.4"
|
||||||
@@ -21,7 +22,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
@@ -29,11 +30,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "VAULT_TOKEN=${{ secrets.VAULT_GITEA_TOKEN }}" >> $GITHUB_ENV
|
echo "VAULT_TOKEN=${{ secrets.VAULT_GITEA_TOKEN }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Gotify Notification
|
- name: Gotify Notification - Start
|
||||||
uses: eikendev/gotify-action@master
|
uses: eikendev/gotify-action@master
|
||||||
with:
|
with:
|
||||||
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
gotify_api_base: ${{ secrets.RUNNER_GOTIFY_URL }}
|
||||||
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
gotify_app_token: ${{ secrets.RUNNER_GOTIFY_TOKEN }}
|
||||||
notification_title: "GITEA: PR Check @ Rinoa"
|
notification_title: "GITEA: PR Check @ Rinoa"
|
||||||
notification_message: "Checking for existing PR... 🔍"
|
notification_message: "Checking for existing PR... 🔍"
|
||||||
|
|
||||||
@@ -43,14 +44,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
url: ${{ secrets.TREZ_GITEA_URL }}
|
url: ${{ secrets.TREZ_GITEA_URL }}
|
||||||
token: ${{ secrets.BOT_GITEA_TOKEN }}
|
token: ${{ secrets.BOT_GITEA_TOKEN }}
|
||||||
pr-label: docker-compose,manual
|
pr-label: "docker-compose,manual"
|
||||||
assignee: ${{ github.actor }}
|
assignee: ${{ github.actor }}
|
||||||
|
|
||||||
- name: Gotify Notification
|
- name: Gotify Notification - Done
|
||||||
uses: eikendev/gotify-action@master
|
uses: eikendev/gotify-action@master
|
||||||
with:
|
with:
|
||||||
gotify_api_base: "${{ secrets.RUNNER_GOTIFY_URL }}"
|
gotify_api_base: ${{ secrets.RUNNER_GOTIFY_URL }}
|
||||||
gotify_app_token: "${{ secrets.RUNNER_GOTIFY_TOKEN }}"
|
gotify_app_token: ${{ secrets.RUNNER_GOTIFY_TOKEN }}
|
||||||
notification_title: "GITEA: PR Check @ Rinoa"
|
notification_title: "GITEA: PR Check @ Rinoa"
|
||||||
notification_message: "PR Check done 🎟️"
|
notification_message: "PR Check done 🎟️"
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ jobs:
|
|||||||
VAULT_TOKEN: ${{ secrets.VAULT_GITEA_TOKEN }}
|
VAULT_TOKEN: ${{ secrets.VAULT_GITEA_TOKEN }}
|
||||||
outputs:
|
outputs:
|
||||||
tofu-cloudflare-plan: ${{ steps.tofu_plan.outputs.plan-output }}
|
tofu-cloudflare-plan: ${{ steps.tofu_plan.outputs.plan-output }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -86,16 +88,12 @@ jobs:
|
|||||||
id: env-vault-vars
|
id: env-vault-vars
|
||||||
run: |
|
run: |
|
||||||
echo "🧩 Cleaning and loading cloudflare/.env into GitHub Actions environment..."
|
echo "🧩 Cleaning and loading cloudflare/.env into GitHub Actions environment..."
|
||||||
|
|
||||||
# 1️⃣ Strip any single or double quotes from the file to avoid invalid URIs or extra quoting
|
|
||||||
sed -i 's/[\"'\'']//g' cloudflare/.env
|
sed -i 's/[\"'\'']//g' cloudflare/.env
|
||||||
|
|
||||||
# 2️⃣ Load all vars into current shell
|
|
||||||
set -a
|
set -a
|
||||||
source cloudflare/.env
|
source cloudflare/.env
|
||||||
set +a
|
set +a
|
||||||
|
|
||||||
# 3️⃣ Export to GitHub Actions environment
|
|
||||||
while IFS='=' read -r key value; do
|
while IFS='=' read -r key value; do
|
||||||
if [[ -n "$key" ]]; then
|
if [[ -n "$key" ]]; then
|
||||||
echo "$key=$value" >> $GITHUB_ENV
|
echo "$key=$value" >> $GITHUB_ENV
|
||||||
@@ -103,7 +101,6 @@ jobs:
|
|||||||
done < cloudflare/.env
|
done < cloudflare/.env
|
||||||
|
|
||||||
repo_name=$(echo "${{ github.repository }}" | awk -F"/" '{print $2}')
|
repo_name=$(echo "${{ github.repository }}" | awk -F"/" '{print $2}')
|
||||||
|
|
||||||
echo "repo_name=$repo_name" >> "$GITHUB_OUTPUT"
|
echo "repo_name=$repo_name" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Run tofu init
|
- name: Run tofu init
|
||||||
@@ -121,26 +118,37 @@ jobs:
|
|||||||
chdir: cloudflare
|
chdir: cloudflare
|
||||||
out: cloudflare.tfplan
|
out: cloudflare.tfplan
|
||||||
|
|
||||||
- name: Comment Tofu Plan on PR
|
- name: Save plan output to file (with collapsible Markdown)
|
||||||
uses: marocchino/sticky-pull-request-comment@v2
|
run: |
|
||||||
|
mkdir -p tmp
|
||||||
|
{
|
||||||
|
echo "## 🧩 OpenTofu Plan — Cloudflare"
|
||||||
|
echo "**Branch:** \`${{ github.ref_name }}\`"
|
||||||
|
echo "**Exit Code:** \`${{ steps.tofu_plan.outputs.exitcode }}\`"
|
||||||
|
echo "**Working Directory:** \`cloudflare\`"
|
||||||
|
echo ""
|
||||||
|
echo "<details><summary>🪶 Click to expand full plan output</summary>"
|
||||||
|
echo ""
|
||||||
|
echo '```hcl'
|
||||||
|
cat <<< "${{ steps.tofu_plan.outputs.plan-output }}"
|
||||||
|
echo '```'
|
||||||
|
echo ""
|
||||||
|
echo "</details>"
|
||||||
|
echo ""
|
||||||
|
echo "*(This plan was automatically generated by the workflow.)*"
|
||||||
|
} > tmp/tofu-plan.md
|
||||||
|
echo "Plan file saved: tmp/tofu-plan.md ($(wc -c < tmp/tofu-plan.md) bytes)"
|
||||||
|
|
||||||
|
- name: Comment full Tofu Plan on PR (safe)
|
||||||
|
uses: https://git.trez.wtf/Trez.One/git-auto-comment@main
|
||||||
with:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.BOT_GITEA_TOKEN }}
|
platform: gitea
|
||||||
header: "🧩 OpenTofu Plan — Cloudflare"
|
api_url: https://git.trez.wtf/api/v1
|
||||||
message: |
|
token: ${{ secrets.BOT_GITEA_TOKEN }}
|
||||||
## 🧩 OpenTofu Plan Result
|
pr_index: ${{ needs.check-and-create-pr.outputs.pr_number }}
|
||||||
**Branch:** `${{ github.ref_name }}`
|
repo_owner: ${{ github.repository_owner }}
|
||||||
**Exit Code:** `${{ steps.tofu_plan.outputs.exitcode }}`
|
repo_name: ${{ steps.env-vault-vars.outputs.repo_name }}
|
||||||
**Working Directory:** `cloudflare`
|
comment_template_path: tmp/tofu-plan.md
|
||||||
|
|
||||||
<details><summary>🪶 Click to expand full plan output</summary>
|
|
||||||
|
|
||||||
```
|
|
||||||
${{ steps.tofu_plan.outputs.plan-output }}
|
|
||||||
```
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
*(This plan was automatically generated by the workflow.)*
|
|
||||||
|
|
||||||
- name: Wait for manual approval
|
- name: Wait for manual approval
|
||||||
uses: trstringer/manual-approval@v1
|
uses: trstringer/manual-approval@v1
|
||||||
@@ -148,59 +156,38 @@ jobs:
|
|||||||
secret: ${{ secrets.BOT_GITEA_TOKEN }}
|
secret: ${{ secrets.BOT_GITEA_TOKEN }}
|
||||||
approvers: WTF
|
approvers: WTF
|
||||||
minimum-approvals: 1
|
minimum-approvals: 1
|
||||||
issue-title: "Tofu Plan for ${{ env.PR_NUMBER }}"
|
issue-title: "Tofu Plan for ${{ needs.check-and-create-pr.outputs.pr_number }}"
|
||||||
issue-body: "Please approve or deny the deployment of the below Tofu plan"
|
issue-body: "Please approve or deny the deployment of the below Tofu plan"
|
||||||
issue-body-file-path: cloudflare.tfplan
|
issue-body-file-path: cloudflare.tfplan
|
||||||
exclude-workflow-initiator-as-approver: false
|
exclude-workflow-initiator-as-approver: false
|
||||||
fail-on-denial: true
|
fail-on-denial: true
|
||||||
additional-approved-words: ''
|
|
||||||
additional-denied-words: ''
|
|
||||||
|
|
||||||
# - name: PR Comment
|
|
||||||
# uses: https://git.trez.wtf/Trez.One/git-auto-comment@main
|
|
||||||
# env:
|
|
||||||
# DEBUG: true
|
|
||||||
# with:
|
|
||||||
# debug: true
|
|
||||||
# platform: gitea
|
|
||||||
# api_url: https://git.trez.wtf/api/v1
|
|
||||||
# token: ${{ secrets.BOT_GITEA_TOKEN }}
|
|
||||||
# pr_index: ${{ needs.check-and-create-pr.outputs.pr_number }}
|
|
||||||
# repo_owner: ${{ github.repository_owner }}
|
|
||||||
# repo_name: ${{ steps.env-vault-vars.outputs.repo_name }}
|
|
||||||
# plan_file: cloudflare/cloudflare.tfplan
|
|
||||||
# comment_template: |
|
|
||||||
# 🚀 **Tofu Plan Output**
|
|
||||||
# ---
|
|
||||||
# ${{ steps.tofu_plan.outputs.plan-output }}
|
|
||||||
# Exit Code: ${{ steps.tofu_plan.outputs.exitcode }}
|
|
||||||
|
|
||||||
# apply:
|
# apply:
|
||||||
# name: Apply Tofu Plan
|
# name: Apply Tofu Plan
|
||||||
# needs: approval
|
# needs: plan-approval
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
# if: ${{ needs.approval.result == 'success' }}
|
# if: ${{ needs.plan-approval.result == 'success' }}
|
||||||
# env:
|
# env:
|
||||||
# VAULT_TOKEN: ${{ secrets.VAULT_GITEA_TOKEN }}
|
# VAULT_TOKEN: ${{ secrets.VAULT_GITEA_TOKEN }}
|
||||||
# steps:
|
# steps:
|
||||||
# - name: Checkout
|
# - name: Checkout
|
||||||
# uses: actions/checkout@v4
|
# uses: actions/checkout@v4
|
||||||
|
#
|
||||||
# - name: Setup OpenTofu
|
# - name: Setup OpenTofu
|
||||||
# uses: opentofu/setup-opentofu@v1.0.6
|
# uses: opentofu/setup-opentofu@v1.0.6
|
||||||
# with:
|
# with:
|
||||||
# version: ${{ env.OPENTOFU_VERSION }}
|
# version: ${{ env.OPENTOFU_VERSION }}
|
||||||
# tofu_wrapper: true
|
# tofu_wrapper: true
|
||||||
|
#
|
||||||
# - name: Export env from Vault
|
# - name: Export env from Vault
|
||||||
# run: |
|
# run: |
|
||||||
# set -a
|
# set -a
|
||||||
# source cloudflare/.env
|
# source cloudflare/.env
|
||||||
# set +a
|
# set +a
|
||||||
|
#
|
||||||
# - name: Run Tofu Apply
|
# - name: Run Tofu Apply
|
||||||
# uses: dnogu/tofu-apply@v1
|
# uses: dnogu/tofu-apply@v1
|
||||||
# with:
|
# with:
|
||||||
# working-directory: .
|
# working-directory: .
|
||||||
# chdir: cloudflare
|
# chdir: cloudflare
|
||||||
# plan: cloudflare.tfplan
|
# plan: cloudflare.tfplan
|
||||||
|
|||||||
Reference in New Issue
Block a user