Merge pull request #8 from liyangau/add-staging-cp #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Apply changes | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**/README.md' | |
jobs: | |
apply-changes: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.8.0 | |
terraform_wrapper: false | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check | |
continue-on-error: true | |
- name: Terraform Init | |
id: init | |
run: terraform init | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_ENDPOINT_URL_S3: ${{ secrets.AWS_ENDPOINT_URL_S3 }} | |
AWS_EC2_METADATA_DISABLED: true | |
- name: Terraform Validate | |
id: validate | |
run: terraform validate -no-color | |
- name: Terraform Plan | |
id: plan | |
run: terraform plan -no-color | |
continue-on-error: false | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_ENDPOINT_URL_S3: ${{ secrets.AWS_ENDPOINT_URL_S3 }} | |
AWS_EC2_METADATA_DISABLED: true | |
TF_VAR_system_token: ${{ secrets.KONNECT_SYSTEM_TOKEN }} | |
TF_VAR_cp_region: "au" | |
TF_VAR_exclude_mesh_control_plane: "true" | |
- name: Terraform Apply | |
id: apply | |
if: github.event_name == 'push' | |
run: terraform apply -no-color -auto-approve -input=false | |
continue-on-error: false | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_ENDPOINT_URL_S3: ${{ secrets.AWS_ENDPOINT_URL_S3 }} | |
AWS_EC2_METADATA_DISABLED: true | |
TF_VAR_system_token: ${{ secrets.KONNECT_SYSTEM_TOKEN }} | |
TF_VAR_cp_region: "au" | |
TF_VAR_exclude_mesh_control_plane: "true" | |
- name: Generate terraform output | |
id: output | |
run: terraform output -no-color -json > ./konnectTFOutput.json | |
continue-on-error: false | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_ENDPOINT_URL_S3: ${{ secrets.AWS_ENDPOINT_URL_S3 }} | |
AWS_EC2_METADATA_DISABLED: true | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: tf-output | |
path: ./konnectTFOutput.json | |
update-tf-output-gist: | |
needs: apply-changes | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: tf-output | |
- name: Upload to Gist | |
uses: exuanbo/[email protected] | |
with: | |
token: ${{ secrets.GH_GIST_TOKEN }} | |
gist_id: ${{ secrets.GIST_ID }} | |
file_path: ./konnectTFOutput.json |