fix: アップロード方法を修正 #11
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/[email protected]' | |
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 }}' | |
- 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: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v1' | |
with: | |
version: '>= 379.0.0' | |
- name: Upload gssc source to cloud storage | |
run: |- | |
gsutil cp iljj-gssc-src.zip gs://${{ vars.BUCKET_NAME }}/iljj-gssc-src.zip | |
- name: Terraform Init | |
run: terraform init | |
- name: Validate Terraform | |
run: terraform validate | |
- name: Terraform Apply | |
run: terraform apply -auto-approve |