Skip to content

Commit

Permalink
Merge pull request #2 from v-ut-d/build-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cm-ayf authored Aug 21, 2022
2 parents 15e5095 + 0744ea0 commit 200716e
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy-ssh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v2
with:
install: true
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v4
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
- uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: 'google-github-actions/auth@v0'
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDP }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- uses: 'google-github-actions/ssh-compute@v0'
with:
instance_name: ${{ secrets.GCP_INSTANCE_NAME }}
zone: 'us-west1-b'
ssh_private_key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
command: |
NAME=$(echo ${{ github.repository }} | sed -e 's#.*/##')
sudo docker rm $NAME
sudo docker run --name $NAME --env-file /var/bots/$NAME.env ghcr.io/${{ github.repository }}:latest

0 comments on commit 200716e

Please sign in to comment.