diff --git a/.github/workflows/hub-branch.yml b/.github/workflows/hub-branch.yml new file mode 100644 index 00000000..3f824e8c --- /dev/null +++ b/.github/workflows/hub-branch.yml @@ -0,0 +1,11 @@ +name: Hub - Branches + +on: + push: + branches-ignore: + - "main" + +jobs: + build: + name: Build + uses: ./.github/workflows/hub-build.yml diff --git a/.github/workflows/hub.yml b/.github/workflows/hub-build.yml similarity index 59% rename from .github/workflows/hub.yml rename to .github/workflows/hub-build.yml index d4f804cd..509104f6 100644 --- a/.github/workflows/hub.yml +++ b/.github/workflows/hub-build.yml @@ -1,19 +1,11 @@ -name: Hub +name: Hub - Build on: - push: - paths: - - "src/Directory.Build.props" - - "src/Worms.Hub*/**" - - "src/database/**" - - "build/docker/**" - - "build/release-github.sh" - - "build/version.sh" - - ".github/workflows/hub.yml" + workflow_call: jobs: build-gateway: - name: Package - Gateway + name: Gateway runs-on: ubuntu-latest steps: @@ -36,7 +28,7 @@ jobs: make gateway.package build-replay-processor: - name: Package - Replay Processor + name: Replay Processor runs-on: ubuntu-latest steps: @@ -59,7 +51,7 @@ jobs: make replay-processor.package build-database: - name: Build - Database + name: Database runs-on: ubuntu-latest env: FLYWAY_EMAIL: ${{ secrets.FLYWAY_EMAIL }} @@ -93,35 +85,3 @@ jobs: info migrate info - - release: - name: Release - runs-on: ubuntu-latest - needs: [build-gateway, build-replay-processor, build-database] - if: github.ref == 'refs/heads/main' - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Expose GitHub Runtime - uses: crazy-max/ghaction-github-runtime@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: theeadie - password: ${{ secrets.DockerHubAccessToken }} - - - name: Release - run: | - make gateway.release GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} - make replay-processor.release GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/hub-main.yml b/.github/workflows/hub-main.yml new file mode 100644 index 00000000..faf18558 --- /dev/null +++ b/.github/workflows/hub-main.yml @@ -0,0 +1,16 @@ +name: Hub - Main + +on: + push: + branches: + - "main" + +jobs: + build: + name: Build + uses: ./.github/workflows/hub-build.yml + + release: + name: Release + needs: build + uses: ./.github/workflows/hub-release.yml diff --git a/.github/workflows/hub-release.yml b/.github/workflows/hub-release.yml new file mode 100644 index 00000000..4e9fcd1c --- /dev/null +++ b/.github/workflows/hub-release.yml @@ -0,0 +1,128 @@ +name: Hub - Release + +on: + workflow_call: + +jobs: + + changes: + name: Detect Changes + runs-on: ubuntu-latest + outputs: + gateway: ${{ steps.filter.outputs.gateway || steps.filter.outputs.common }} + replay-processor: ${{ steps.filter.outputs.replay-processor || steps.filter.outputs.common }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Filter + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + gateway: + - 'src/Worms.Hub.Gateway/**' + - 'src/Worms.Hub.Storage/**' + replay-processor: + - 'src/Worms.Hub.ReplayProcessor/**' + - 'src/Worms.Hub.Storage/**' + - 'src/Worms.Armageddon.Game/**' + common: + - 'src/Directory.Build.props' + - '.github/workflows/hub-*.yml' + - 'build/docker/**' + + release-gateway-github: + name: Gateway - GitHub + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.gateway == 'true' && github.ref == 'refs/heads/main' }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Release + run: | + make gateway.release.github GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} + + release-gateway-dockerhub: + name: Gateway - DockerHub + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.gateway == 'true' && github.ref == 'refs/heads/main' }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: theeadie + password: ${{ secrets.DockerHubAccessToken }} + + - name: Release + run: | + make gateway.release.dockerhub + + release-replay-processor-github: + name: Replay Processor - GitHub + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.replay-processor == 'true' && github.ref == 'refs/heads/main' }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Release + run: | + make replay-processor.release.github GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} + + release-replay-processor-dockerhub: + name: Replay Processor - DockerHub + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.replay-processor == 'true' && github.ref == 'refs/heads/main' }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: theeadie + password: ${{ secrets.DockerHubAccessToken }} + + - name: Release + run: | + make replay-processor.release.dockerhub