Skip to content

Commit

Permalink
fixed compute engine deploy to use ssh with authorized user
Browse files Browse the repository at this point in the history
  • Loading branch information
excute committed Nov 17, 2023
1 parent f5731e5 commit bbb917c
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions .github/workflows/cicd-branch-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Google Auth
id: google-auth
Expand All @@ -32,21 +32,21 @@ jobs:
workload_identity_provider: "${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}"
service_account: "${{ secrets.GOOGLE_SERVICE_ACCOUNT }}"

# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# - name: Build and push
# uses: docker/build-push-action@v5
# with:
# build-args: |
# DISCORD_BOT_TOKEN=${{ secrets.DISCORD_BOT_TOKEN }}
# DISCORD_BOT_LOG_GUILD_ID=${{ vars.DISCORD_BOT_LOG_GUILD_ID }}
# DISCORD_BOT_LOG_CHANNEL_ID=${{ vars.DISCORD_BOT_LOG_CHANNEL_ID }}
# tags: ${{ env.IMAGE_TAG }}
# push: true
- name: Build and push
uses: docker/build-push-action@v5
with:
build-args: |
DISCORD_BOT_TOKEN=${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_BOT_LOG_GUILD_ID=${{ vars.DISCORD_BOT_LOG_GUILD_ID }}
DISCORD_BOT_LOG_CHANNEL_ID=${{ vars.DISCORD_BOT_LOG_CHANNEL_ID }}
tags: ${{ env.IMAGE_TAG }}
push: true

- name: Deploy to Compute engine
id: deploy
Expand All @@ -56,15 +56,13 @@ jobs:
zone: asia-northeast3-a
ssh_private_key: "${{ secrets.GCP_SSH_PRIVATE_KEY }}"
user: oys
# command: |-
# "docker pull ${{ env.IMAGE_TAG }} \
# && docker stop $(docker ps -aq) \
# && docker run ${{ env.IMAGE_TAG }} \
# && docker image prune -a"
command: |-
whoami && docker help
"docker pull ${{ env.IMAGE_TAG }} \
&& docker stop $(docker ps -aq) \
&& docker run ${{ env.IMAGE_TAG }} \
&& docker image prune -a"
- name: Show Output
run: |-
echo ${{ steps.deploy.outputs.stdout }}
echo ${{ steps.deploy.outputs.stderr }}
echo `${{ steps.deploy.outputs.stdout }}`
echo `${{ steps.deploy.outputs.stderr }}`

0 comments on commit bbb917c

Please sign in to comment.