Skip to content

deploy-instances

deploy-instances #76

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
# push:
# branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
repository_dispatch:
types: [deploy-instances]
env:
TF_REGISTRY_CLIENT_TIMEOUT: 30
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ALICLOUD_ACCESS_KEY: ${{ secrets.ALICLOUD_ACCESS_KEY }}
ALICLOUD_SECRET_KEY: ${{ secrets.ALICLOUD_SECRET_KEY }}
ALICLOUD_REGION: ${{ secrets.ALICLOUD_REGION }}
ALICLOUD_BUCKET: ${{ secrets.ALICLOUD_BUCKET }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform init -backend-config="bucket=${{ env.ALICLOUD_BUCKET }}"
# Runs a single command using the runners shell
- name: Download Terraform input file
run: ./download-oss-file.sh inputs/terraform.tfvars.json terraform.tfvars.json
# for test
# - name: Run a one-line script
# run: cat terraform.tfvars.json
# Generates an execution plan for Terraform
- name: Terraform Plan
run: terraform plan -input=false
env:
TF_VAR_output_oss_bucket: ${{ secrets.ALICLOUD_BUCKET }}
# On push to "main", build or change infrastructure according to Terraform configuration files
# Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks
- name: Terraform Apply
run: terraform apply -auto-approve -input=false
env:
TF_VAR_output_oss_bucket: ${{ secrets.ALICLOUD_BUCKET }}