Skip to content

Commit

Permalink
Updated build script
Browse files Browse the repository at this point in the history
  • Loading branch information
loffa committed Apr 17, 2024
1 parent 2a50642 commit 84eb2f3
Showing 1 changed file with 41 additions and 33 deletions.
74 changes: 41 additions & 33 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,48 @@ name: Build & Deploy
on:
push:
branches:
- master
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Build container
id: docker_build
uses: docker/build-push-action@v2
with:
load: true
tags: insektionen/control-app:latest
build-args: |
"ARG_USERNAME=${{secrets.DB_USERNAME}}"
"ARG_PASSWORD=${{secrets.DB_PASSWORD}}"
"ARG_CLUSTER=${{secrets.DB_CLUSTER}}"
"ARG_DATABASE=${{secrets.DB_DATABASE}}"
"ARG_API_URL=${{secrets.NEXT_PUBLIC_API_URL}}"
"ARG_MQTT_URL=${{secrets.MQTT_URL}}"
- name: Export container
run: docker save insektionen/control-app:latest | gzip > control-app_latest.tar.gz
- name: Copy to Server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: 22
source: "control-app_latest.tar.gz"
target: "~/"
- name: Import and start on Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: 22
script: docker load < control-app_latest.tar.gz && cd control-app && docker-compose up -d
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build container
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"ARG_USERNAME=${{secrets.DB_USERNAME}}"
"ARG_PASSWORD=${{secrets.DB_PASSWORD}}"
"ARG_CLUSTER=${{secrets.DB_CLUSTER}}"
"ARG_DATABASE=${{secrets.DB_DATABASE}}"
"ARG_API_URL=${{secrets.NEXT_PUBLIC_API_URL}}"
"ARG_MQTT_URL=${{secrets.MQTT_URL}}"
# - name: Import and start on Server
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SSH_HOST }}
# username: ${{ secrets.SSH_USERNAME }}
# key: ${{ secrets.SSH_KEY }}
# port: 22
# script: cd control-app && docker compose up -d --pull

0 comments on commit 84eb2f3

Please sign in to comment.