Update .gitea/workflows/tf-apply.yml
This commit is contained in:
@@ -16,83 +16,9 @@ on:
|
|||||||
type: string
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tf-plan:
|
|
||||||
name: Terraform Plan
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
tfplanexitcode: ${{ steps.tfplan.outputs.exitcode }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Clone blackbox repo
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: xaked/blackbox
|
|
||||||
path: blackbox
|
|
||||||
ref: master
|
|
||||||
- name: Install blackbox
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd blackbox || exit 1;
|
|
||||||
make copy-install;
|
|
||||||
cd ${{ github.workspace }};
|
|
||||||
rm -rf blackbox;
|
|
||||||
- uses: hashicorp/setup-terraform@v2
|
|
||||||
with:
|
|
||||||
terraform_version: 1.5.7
|
|
||||||
cli_config_credentials_token: ${{ secrets.tf-api-token }}
|
|
||||||
- name: Clone repo
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Decrypt secrets
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo ${{ secrets.gpg-key }} | base64 -d | gpg --import;
|
|
||||||
blackbox_decrypt_all_files;
|
|
||||||
- name: Setup SSH key
|
|
||||||
uses: benoitchantre/setup-ssh-authentication-action@1.0.1
|
|
||||||
with:
|
|
||||||
private-key: ${{ secrets.ssh-private-key }}
|
|
||||||
private-key-name: id_ed25519
|
|
||||||
known-hosts: ${{ secrets.ssh-known-hosts }}
|
|
||||||
- name: Restore terraform cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: cache-terraform-restore
|
|
||||||
with:
|
|
||||||
path: .terraform
|
|
||||||
key: ${{ github.repository }}-${{ runner.os }}-${{ runner.arch }}-tf
|
|
||||||
- name: Run terraform init
|
|
||||||
shell: bash
|
|
||||||
run: terraform init
|
|
||||||
- name: Run terraform validate
|
|
||||||
shell: bash
|
|
||||||
run: terraform validate
|
|
||||||
- name: Run terraform plan
|
|
||||||
id: tfplan
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
terraform plan -detailed-exitcode -out=tfplan.binary -input=false;
|
|
||||||
continue-on-error: true
|
|
||||||
- name: Check if job errored
|
|
||||||
if: ${{ steps.tfplan.outputs.exitcode == 1 }}
|
|
||||||
shell: sh
|
|
||||||
run: exit 1
|
|
||||||
- name: Upload terraform plan if diffs are detected
|
|
||||||
if: ${{ steps.tfplan.outputs.exitcode == 2 }}
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: tfplan
|
|
||||||
path: tfplan.binary
|
|
||||||
- name: Save terraform cache
|
|
||||||
uses: actions/cache/save@v3
|
|
||||||
id: cache-terraform-save
|
|
||||||
with:
|
|
||||||
path: .terraform
|
|
||||||
key: ${{ steps.cache-terraform-restore.outputs.cache-primary-key }}
|
|
||||||
|
|
||||||
tf-apply:
|
tf-apply:
|
||||||
name: Terraform Apply
|
name: Terraform Apply
|
||||||
needs: tf-plan
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: needs.tf-plan.outputs.tfplanexitcode == 2
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone blackbox repo
|
- name: Clone blackbox repo
|
||||||
|
|||||||
Reference in New Issue
Block a user