-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,51 @@ | ||
- name: Deploy to SSH server | ||
name: CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- id: "auth" | ||
uses: "google-github-actions/auth@v2" | ||
with: | ||
credentials_json: "${{ secrets.GCP_SA_KEY }}" | ||
|
||
- name: "Set up Cloud SDK" | ||
uses: "google-github-actions/setup-gcloud@v2" | ||
|
||
- name: "Use gcloud CLI" | ||
run: "gcloud info" | ||
|
||
- name: Configure Docker for Artifact Registry | ||
run: | | ||
gcloud auth configure-docker ${{ secrets.GCE_REGION }}-docker.pkg.dev | ||
- name: Build and push Docker image | ||
env: | ||
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} | ||
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | ||
GITHUB_SHA: ${{ github.sha }} | ||
GCE_REGION: ${{ secrets.GCE_REGION }} | ||
BUCKET_NAME: ${{ secrets.BUCKET_NAME }} | ||
run: | | ||
echo "$GCP_SA_KEY" > gcp-service-account-key.json | ||
docker build --build-arg DATABASE_URL=${{ secrets.DATABASE_URL }} --build-arg GCS_BUCKET_NAME=$BUCKET_NAME --build-arg GCP_SA_KEY="$GCP_SA_KEY" -t $GCE_REGION-docker.pkg.dev/$PROJECT_ID/arsip-template/app:$GITHUB_SHA . | ||
docker push $GCE_REGION-docker.pkg.dev/$PROJECT_ID/arsip-template/app:$GITHUB_SHA | ||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: Deploy to SSH server | ||
env: | ||
REGION: ${{ secrets.GCE_REGION }} | ||
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | ||
|
@@ -30,4 +77,4 @@ | |
docker-compose pull | ||
docker-compose down | ||
docker-compose up -d | ||
' | ||
' |