From f5d0f85cd09f359faa1b5f27890dc738a3f464fc Mon Sep 17 00:00:00 2001 From: DaniDipp Date: Mon, 15 Apr 2024 20:30:30 +0000 Subject: [PATCH] add deployment workflow --- .github/workflows/deploy.yml | 83 ++++++++++++++++++++++++++++++++++++ Dockerfile | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..a222f5599 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,83 @@ +name: Deploy +on: + workflow_dispatch: + +jobs: + build_jar: + name: Build Jar + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + cache: maven + - name: Build with Maven + run: mvn --batch-mode --update-snapshots verify + - name: Rename jar + run: mv target/*-All.jar JMusicBot-Snapshot-All.jar + - name: Upload jar + uses: actions/upload-artifact@v3 + with: + name: jar + path: JMusicBot-Snapshot-All.jar + if-no-files-found: error + deploy: + name: Deploy Docker + runs-on: ubuntu-latest + needs: build_jar + steps: + - name: Test dokcer credentials with curl + run: curl -X GET -u ${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }} -L https://${{ secrets.DOCKER_REGISTRY }}/v2/mother-mouse-musicbot/tags/list + - name: Checkout + uses: actions/checkout@v4 + - name: Download a Build Artifact + uses: actions/download-artifact@v3.0.0 + with: + name: jar + path: ./target/ + - name: Show Artifacts + run: ls -R + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + buildkitd-flags: --debug + # - name: Login to Docker + # uses: docker/login-action@v3 + # with: + # registry: ${{ secrets.DOCKER_REGISTRY }} + # username: ${{ secrets.DOCKER_USERNAME }} + # password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Set up containerd + uses: crazy-max/ghaction-setup-containerd@v2 + - name: Verify credentials + run: | + sudo ctr --debug i fetch --user "${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }}" ${{ secrets.DOCKER_REGISTRY }}/mother-mouse-musicbot:latest + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64 + tags: ${{ secrets.DOCKER_REGISTRY }}/mother-mouse-musicbot:latest + outputs: type=oci,dest=/tmp/image.tar + - name: Import image in containerd + run: | + sudo ctr i import --base-name ${{ secrets.DOCKER_REGISTRY }}/mother-mouse-musicbot --digests --all-platforms /tmp/image.tar + - name: Push image with containerd + run: | + sudo ctr --debug i push --user "${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }}" ${{ secrets.DOCKER_REGISTRY }}/mother-mouse-musicbot:latest + # - name: Deploy to Docker + # uses: docker/build-push-action@v5 + # with: + # tags: ${{ secrets.DOCKER_REGISTRY }}/mother-mouse-musicbot:latest + # context: . + # push: true + - name: Trigger Watchtower via curl + run: | + curl -L -I -H "Authorization: Bearer ${{ secrets.WATCHTOWER_TOKEN }}" "${{ secrets.WATCHTOWER_URL }}" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 47fb59ea2..2389c3256 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:8 +FROM eclipse-temurin:11-jre-alpine WORKDIR /musicbot