Skip to content

Commit

Permalink
feat(ci): use artifact registry for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
rorre committed Jun 19, 2024
1 parent b2daddd commit 7e8c7b3
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,34 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
environment: Deploy
steps:
- name: Checkout
uses: actions/checkout@v3

- name: "Authenticate Google Cloud"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"

- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
- name: Build Docker Image
run: |
mkdir ./keys
echo '${{ secrets.CREDENTIALS }}' > ./keys/credentials.json
ls
ls ./keys
docker build -t chefies-backend .
- name: Save Docker Image as TAR File
run: |
docker save -o chefies-backend.tar chefies-backend
- name: Send TAR File to Server
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEPLOYMENT_HOST }}
username: ${{ secrets.DEPLOYMENT_HOST_USERNAME }}
key: ${{ secrets.DEPLOYMENT_HOST_KEY }}
port: 22
source: chefies-backend.tar
target: images/
docker build --tag ${{ env.GAR_LOCATION }} .
- name: Push image
run: docker push ${{ env.GAR_LOCATION }}

- name: Run Docker Image
uses: appleboy/[email protected]
with:
Expand All @@ -40,5 +46,4 @@ jobs:
script: |
docker container rm -f chefies-backend
docker image rm -f chefies-backend
docker load -i images/chefies-backend.tar
docker run --name chefies-backend -e GOOGLE_APPLICATION_CREDENTIALS="/app/keys/credentials.json" -d --restart always -p 9000:80 chefies-backend
docker run --name chefies-backend -e GOOGLE_APPLICATION_CREDENTIALS="/app/keys/credentials.json" -d --restart always -p 9000:80 ${{ env.GAR_LOCATION }}

0 comments on commit 7e8c7b3

Please sign in to comment.