From bb30ac7db4dc32573c16ce04e61c583cae9eb23a Mon Sep 17 00:00:00 2001 From: Jesper Falk Date: Wed, 17 Apr 2024 19:36:13 +0200 Subject: [PATCH] Updated CI pipeline --- .github/workflows/build-and-deploy.yml | 55 +++++++++++++------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 6b955b7..13219ed 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -1,34 +1,35 @@ -name: Build & Deploy +name: Build 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/x32-mqtt:latest - - name: Export container - run: docker save insektionen/x32-mqtt:latest | gzip > x32-mqtt_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: "x32-mqtt_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 < x32-mqtt_latest.tar.gz && cd x32-mqtt && 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 }} +