diff --git a/.github/workflows/build.yaml b/.github/workflows/release.yaml similarity index 58% rename from .github/workflows/build.yaml rename to .github/workflows/release.yaml index c9041d5..5fb6d40 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/release.yaml @@ -1,11 +1,11 @@ -name: 'Build' +name: 'Release' on: push: tags: - 'v*.*.*' -env: +env: MIGRATOR_IMAGE: 'ghcr.io/nijeti/cinema-keeper-migrator' MIGRATOR_DOCKERFILE: 'build/migrator/Dockerfile' @@ -84,3 +84,60 @@ jobs: context: . tags: ${{ steps.meta.outputs.tags }} push: true + + deploy: + runs-on: ubuntu-latest + + needs: + - build-migrator + - build-service + + environment: + name: prod + + permissions: + contents: read + packages: read + + steps: + - name: 'Checkout' + uses: actions/checkout@v4 + + - name: 'Calculate version' + run: + VERSION=${GITHUB_REF_NAME#v} + echo Deploying version $VERSION + echo 'VERSION=$VERSION' >> $GITHUB_ENV + + - name: 'Login to container registry' + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: | + docker login \ + -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} \ + ghcr.io + + - name: 'Copy docker-compose.yaml' + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + source: docker-compose.yaml + target: ${{ secrets.PATH }} + + - name: 'Run containers from docker-compose.yaml' + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: | + cd ${{ secrets.PATH }} + VERSION=$VERSION docker compose up -d