From 4a627cc8b03c85eb8150abb79a9ca8cb4e7a2f9a Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 14 Apr 2024 15:53:03 +0700 Subject: [PATCH 1/2] added: deploy using github packages --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 673c8c5..48bf9f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,23 +1,43 @@ -name: deployment on server +name: Create and publish a Docker image on: push: - branches: [ master ] + branches: + - main + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: - build: + build-and-push-image: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + permissions: + contents: read + packages: write - - name: update bot - uses: appleboy/ssh-action@v1.0.3 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: - host: ${{ secrets.SERVER_HOST }} - username: ${{ secrets.SERVER_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - port: 22 - script: | - cd /home/deploy/vatsimfox && git pull origin master --force && cd /home/deploy/vatsimfox/src - docker compose up -d --build + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: src/. + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 9ba02586ad18d60542b88ef051b81193d3eb1427 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 14 Apr 2024 15:54:17 +0700 Subject: [PATCH 2/2] fixed: repo name changed --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48bf9f9..b59cbb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: Create and publish a Docker image on: push: branches: - - main + - master env: REGISTRY: ghcr.io