|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - '**.md' |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + gradle: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Setup Java |
| 18 | + uses: actions/setup-java@v3 |
| 19 | + with: |
| 20 | + distribution: zulu |
| 21 | + java-version: 13 |
| 22 | + cache: gradle |
| 23 | + |
| 24 | + - name: Setup Gradle |
| 25 | + uses: gradle/gradle-build-action@v2 |
| 26 | + |
| 27 | + - name: Execute Gradle build |
| 28 | + run: ./gradlew build |
| 29 | + |
| 30 | + - name: Upload Artifacts |
| 31 | + uses: actions/upload-artifact@v3 |
| 32 | + with: |
| 33 | + name: Lavalink.jar |
| 34 | + path: LavalinkServer/build/libs/Lavalink.jar |
| 35 | + |
| 36 | + docker: |
| 37 | + needs: gradle |
| 38 | + runs-on: ubuntu-latest |
| 39 | + if: github.event_name != 'pull_request' |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v2 |
| 43 | + |
| 44 | + - name: Download Artifacts |
| 45 | + uses: actions/download-artifact@v2 |
| 46 | + with: |
| 47 | + name: Lavalink.jar |
| 48 | + |
| 49 | + - name: Docker Meta |
| 50 | + id: meta |
| 51 | + uses: docker/metadata-action@v4 |
| 52 | + with: |
| 53 | + images: | |
| 54 | + fredboat/lavalink |
| 55 | + tags: | |
| 56 | + type=ref,event=branch |
| 57 | + type=ref,event=tag |
| 58 | + type=ref,event=pr |
| 59 | + type=sha,prefix= |
| 60 | +
|
| 61 | + - name: Set up QEMU |
| 62 | + uses: docker/setup-qemu-action@v2 |
| 63 | + |
| 64 | + - name: Set up Docker Buildx |
| 65 | + uses: docker/setup-buildx-action@v2 |
| 66 | + |
| 67 | + - name: Login to DockerHub |
| 68 | + uses: docker/login-action@v2 |
| 69 | + with: |
| 70 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 71 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 72 | + |
| 73 | + - name: Build and push |
| 74 | + uses: docker/build-push-action@v3 |
| 75 | + with: |
| 76 | + file: LavalinkServer/docker/Dockerfile |
| 77 | + context: . |
| 78 | + platforms: linux/amd64,linux/arm/v7 |
| 79 | + push: true |
| 80 | + tags: ${{ steps.meta.outputs.tags }} |
| 81 | + labels: ${{ steps.meta.outputs.labels }} |
| 82 | + |
| 83 | + release: |
| 84 | + needs: gradle |
| 85 | + runs-on: ubuntu-latest |
| 86 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
| 87 | + steps: |
| 88 | + - name: Checkout |
| 89 | + uses: actions/checkout@v2 |
| 90 | + |
| 91 | + - name: Download Artifacts |
| 92 | + uses: actions/download-artifact@v2 |
| 93 | + with: |
| 94 | + name: Lavalink.jar |
| 95 | + |
| 96 | + - name: Upload Artifacts to GitHub Release |
| 97 | + uses: softprops/action-gh-release@v1 |
| 98 | + with: |
| 99 | + files: Lavalink.jar |
0 commit comments