Revert "Revert "fix: workflow error"" #14
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: deploy gcp using terraform | |
on: | |
push: | |
branches: | |
- main | |
defaults: | |
run: | |
working-directory: ./ | |
jobs: | |
initial-command: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: initial | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
- run: npm install | |
- run: node append-command.js | |
env: | |
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} | |
DISCORD_GUILD: ${{ secrets.DISCORD_GUILD }} | |
terraform-workflow: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
create_credentials_file: true | |
workload_identity_provider: 'projects/${{ vars.PROJECT_ID }}/locations/global/workloadIdentityPools/${{ vars.POOL_ID }}/providers/${{ vars.PROVIDER_ID }}' | |
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}' | |
token_format: 'access_token' | |
- uses: hashicorp/setup-terraform@v2 | |
- name: Set terraform valiables | |
run: |- | |
echo "export TF_VAR_bucket_name=${{ vars.BUCKET_NAME }}" >> $GITHUB_ENV | |
echo "export TF_VAR_discord_token=${{ secrets.DISCORD_TOKEN }}" >> $GITHUB_ENV | |
echo "export TF_VAR_project_id=${{ vars.PROJECT_ID }}" >> $GITHUB_ENV | |
echo "export TF_VAR_region=${{ vars.REGION }}" >> $GITHUB_ENV | |
echo "export TF_VAR_client_public_key=${{ vars.CLIENT_PUBLIC_KEY }}" >> $GITHUB_ENV | |
- name: Zip gssc source | |
uses: montudor/[email protected] | |
with: | |
args: zip -qq -r iljj-gssc-src.zip src | |
- name: Upload gssc source to cloud storage | |
uses: 'google-github-actions/upload-cloud-storage@v1' | |
with: | |
destination: ${{ vars.BUCKET_NAME }} | |
path: 'iljj-gssc-src.zip' | |
parent: false | |
process_gcloudignore: false | |
- name: Terraform Init | |
run: terraform init | |
- name: Validate Terraform | |
run: terraform validate | |
- name: Terraform Apply | |
run: terraform apply -auto-approve |