87 lines
2.2 KiB
YAML
87 lines
2.2 KiB
YAML
name: Gitea Deploy to GCP
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
branches:
|
|
- deploy-prd
|
|
- deploy-dev
|
|
|
|
jobs:
|
|
gcp-deploy:
|
|
name: Deploy to GCP
|
|
runs-on: gcloud-tf
|
|
env:
|
|
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
|
|
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
|
|
REPO_NAME: ${{ github.repository }}
|
|
HASH_SUFFIX: ${{ github.sha }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Check Deploy Tools
|
|
run: |
|
|
ls -la
|
|
echo "Checking gcloud and terraform versions..."
|
|
gcloud --version
|
|
terraform --version
|
|
|
|
- name: Check Gcloud auth
|
|
run: |
|
|
echo "HOME: ${HOME}"
|
|
printf '%s' "$GCP_SA_KEY" > $HOME/sa.json
|
|
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/sa.json"
|
|
|
|
gcloud auth activate-service-account --key-file="$GOOGLE_APPLICATION_CREDENTIALS"
|
|
gcloud config set project "$GCP_PROJECT_ID"
|
|
|
|
echo "Check gcloud"
|
|
gcloud config list
|
|
gcloud --version
|
|
|
|
- name: Exec Terraform init shell
|
|
run: |
|
|
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/sa.json"
|
|
./scripts/deploy/init_terraform.sh
|
|
- name: Exec Container Image Push to Artifact Registry
|
|
run: |
|
|
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/sa.json"
|
|
./scripts/deploy/build_image_to_gar.sh
|
|
|
|
|
|
|
|
# steps:
|
|
# - name: Checkout code
|
|
# uses: actions/checkout@v3
|
|
|
|
# checkout:
|
|
# name: Checkout code
|
|
# runs-on: ubuntu-latest
|
|
# steps:
|
|
# - name: Checkout code
|
|
# uses: actions/checkout@v3
|
|
|
|
# gcp-deploy:
|
|
# name: Deploy to GCP
|
|
# runs-on: gcloud-tf
|
|
# steps:
|
|
# - name: Check Deploy Tools
|
|
# run: |
|
|
# gcloud --version
|
|
# terraform --version
|
|
# ls -la
|
|
|
|
|
|
# - name: Set up Cloud SDK
|
|
# uses: google-github-actions/setup-gcloud@v1
|
|
# with:
|
|
# project_id: ${{ secrets.GCP_PROJECT_ID }}
|
|
# service_account_key: ${{ secrets.GCP_SA_KEY }}
|
|
# export_default_credentials: true
|
|
|
|
# - name: Run deployment script
|
|
# run: |
|
|
# chmod +x ./deploy.sh
|
|
# ./deploy.sh
|