Skip to content

Commit

Permalink
test deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
iyoubee committed Jun 2, 2024
1 parent bcea266 commit b7fa392
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
GCE_INSTANCE_NAME: ${{ secrets.GCE_INSTANCE_NAME }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
GCP_REGION: ${{ secrets.GCP_REGION }}
GCP_ZONE: ${{ secrets.GCP_ZONE }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}

Expand Down Expand Up @@ -37,12 +38,12 @@ jobs:

- name: Configure docker for Artifact Registry
run: |
gcloud --quiet auth configure-docker $GCP_ZONE-docker.pkg.dev
gcloud --quiet auth configure-docker $GCP_REGION:-docker.pkg.dev
- name: Build and push Docker image
run: |
docker build -t $GCP_ZONE-docker.pkg.dev/$GCP_PROJECT_ID/$APP_NAME:latest .
docker push $GCP_ZONE-docker.pkg.dev/$GCP_PROJECT_ID/$APP_NAME:latest
docker build -t $GCP_REGION:-docker.pkg.dev/$GCP_PROJECT_ID/ulascan/$APP_NAME:latest .
docker push $GCP_REGION:-docker.pkg.dev/$GCP_PROJECT_ID/ulascan/$APP_NAME:latest
deploy:
needs: build
Expand All @@ -62,11 +63,11 @@ jobs:
ssh -o StrictHostKeyChecking=no \
-i ssh_key \
ulascan@$GCE_INSTANCE_IP \
"gcloud --quiet auth configure-docker $GCP_ZONE-docker.pkg.dev \
&& docker pull $GCP_ZONE-docker.pkg.dev/$GCP_PROJECT_ID/$APP_NAME:latest \
"gcloud --quiet auth configure-docker $GCP_REGION:-docker.pkg.dev \
&& docker pull $GCP_REGION:-docker.pkg.dev/$GCP_PROJECT_ID/$APP_NAME:latest \
&& docker stop $APP_NAME || true \
&& docker rm --force $APP_NAME || true \
&& docker run -d --name $APP_NAME -p 8080:80 $GCP_ZONE-docker.pkg.dev/$GCP_PROJECT_ID/$APP_NAME:latest \
&& docker run -d --name $APP_NAME -p 8080:80 $GCP_REGION:-docker.pkg.dev/$GCP_PROJECT_ID/$APP_NAME:latest \
&& docker image prune -f"
- name: Cleanup SSH key
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY . .

RUN go mod download && go mod verify

RUN go build -v -o main .
RUN go build -o main .

EXPOSE 8080

Expand Down

0 comments on commit b7fa392

Please sign in to comment.