diff --git a/.github/workflows/dispatcher.yml b/.github/workflows/dispatcher.yml new file mode 100644 index 00000000..75563b2f --- /dev/null +++ b/.github/workflows/dispatcher.yml @@ -0,0 +1,25 @@ +name: Pull Request Dispatcher + +on: + issue_comment: + types: + - created + +jobs: + slash_command_dispatch: + name: Slash Command Dispatcher + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Slash Command Dispatch + uses: peter-evans/slash-command-dispatch@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + reaction-token: ${{ secrets.GITHUB_TOKEN }} + commands: | + test + destroy + permission: maintain + issue-type: pull-request + event-type-suffix: -command diff --git a/.github/workflows/handler-text.yml b/.github/workflows/handler-text.yml new file mode 100644 index 00000000..ed7ef939 --- /dev/null +++ b/.github/workflows/handler-text.yml @@ -0,0 +1,65 @@ +name: Pull Request Test Handler + +on: + repository_dispatch: + types: + - test-command + +env: + GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + GOOGLE_REGION: ${{ secrets.GOOGLE_REGION }} + GOOGLE_ZONE: ${{ secrets.GOOGLE_ZONE }} + K6_WORK_DIR_PATH: ${{ secrets.K6_WORK_DIR_PATH }} + +jobs: + public-dns-with-cloud-dns: + name: Public DNS with Cloud DNS + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: "~1" + + - name: Install k6 for load testing + working-directory: ${{ env.K6_WORK_DIR_PATH }} + env: + K6_URL: https://github.com/loadimpact/k6/releases/download/v0.31.1/k6-v0.31.1-linux64.tar.gz + run: | + sudo apt-get install jq + curl -L $K6_URL | tar -xz --strip-components=1 + + - name: Authenticate with Google Cloud + id: auth + uses: google-github-actions/auth@v2 + with: + credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}" + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v2 + with: + version: ">= 363.0.0" + + - name: Terraform Init + id: init + run: terraform init -input=false -no-color + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Retrieve Health Check URL + id: retrieve-health-check-url + working-directory: ${{ env.WORK_DIR_PATH }} + run: | + terraform output -no-color -raw health_check_url + + - name: Terraform Destroy + id: destroy + if: ${{ always() }} + run: terraform destroy -auto-approve -input=false -no-color diff --git a/.github/workflows/tf-lint.yaml b/.github/workflows/tf-lint.yaml new file mode 100644 index 00000000..253a6bcc --- /dev/null +++ b/.github/workflows/tf-lint.yaml @@ -0,0 +1,24 @@ +name: Terraform Lint Check + +on: [push] + +jobs: + tflint: + name: Run tflint + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: "~1" + + - name: Install tflint + run: | + curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash + + - name: Run tflint + run: tflint