ci(workflows): scope persistence workflows to tracker-core changes #2879
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Container | |
| on: | |
| push: | |
| branches: | |
| - "develop" | |
| - "main" | |
| - "releases/**/*" | |
| pull_request: | |
| branches: | |
| - "develop" | |
| - "main" | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| test: | |
| name: Test (Docker) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| target: [debug, release] | |
| steps: | |
| - id: checkout | |
| name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| - id: setup | |
| name: Setup Toolchain | |
| uses: docker/setup-buildx-action@v4 | |
| - id: build | |
| name: Build | |
| uses: docker/build-push-action@v7 | |
| with: | |
| file: ./Containerfile | |
| push: false | |
| load: true | |
| target: ${{ matrix.target }} | |
| tags: torrust-tracker:local | |
| cache-from: type=gha,scope=container-${{ matrix.target }} | |
| cache-to: type=gha,scope=container-${{ matrix.target }},mode=max | |
| - id: inspect | |
| name: Inspect | |
| run: docker image inspect torrust-tracker:local | |
| - id: compose | |
| name: Compose | |
| run: | | |
| QBT_E2E_WORKDIR="${RUNNER_TEMP}/qbt-e2e-compose-build" | |
| mkdir -p "${QBT_E2E_WORKDIR}/tracker-storage" | |
| mkdir -p "${QBT_E2E_WORKDIR}/seeder-config" | |
| mkdir -p "${QBT_E2E_WORKDIR}/seeder-downloads" | |
| mkdir -p "${QBT_E2E_WORKDIR}/leecher-config" | |
| mkdir -p "${QBT_E2E_WORKDIR}/leecher-downloads" | |
| mkdir -p "${QBT_E2E_WORKDIR}/shared" | |
| export QBT_E2E_TRACKER_IMAGE=torrust-tracker:local | |
| export QBT_E2E_QBITTORRENT_IMAGE=ghcr.io/linuxserver/qbittorrent:latest | |
| export QBT_E2E_TRACKER_CONFIG_PATH=./share/default/config/tracker.container.sqlite3.toml | |
| export QBT_E2E_TRACKER_STORAGE_PATH="${QBT_E2E_WORKDIR}/tracker-storage" | |
| export QBT_E2E_TRACKER_HTTP_TRACKER_PORT=7070 | |
| export QBT_E2E_TRACKER_UDP_PORT=6969 | |
| export QBT_E2E_TRACKER_HTTP_API_PORT=1212 | |
| export QBT_E2E_TRACKER_HEALTH_CHECK_API_PORT=1313 | |
| export QBT_E2E_SEEDER_CONFIG_PATH="${QBT_E2E_WORKDIR}/seeder-config" | |
| export QBT_E2E_SEEDER_DOWNLOADS_PATH="${QBT_E2E_WORKDIR}/seeder-downloads" | |
| export QBT_E2E_LEECHER_CONFIG_PATH="${QBT_E2E_WORKDIR}/leecher-config" | |
| export QBT_E2E_LEECHER_DOWNLOADS_PATH="${QBT_E2E_WORKDIR}/leecher-downloads" | |
| export QBT_E2E_SHARED_PATH="${QBT_E2E_WORKDIR}/shared" | |
| docker compose -f compose.qbittorrent-e2e.sqlite3.yaml build | |
| docker compose -f compose.qbittorrent-e2e.mysql.yaml build | |
| docker compose -f compose.qbittorrent-e2e.postgresql.yaml build | |
| context: | |
| name: Context | |
| needs: test | |
| runs-on: ubuntu-latest | |
| outputs: | |
| continue: ${{ steps.check.outputs.continue }} | |
| type: ${{ steps.check.outputs.type }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - id: check | |
| name: Check Context | |
| run: | | |
| if [[ "${{ github.repository }}" == "torrust/torrust-tracker" ]]; then | |
| if [[ "${{ github.event_name }}" == "push" ]]; then | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| echo "type=development" >> $GITHUB_OUTPUT | |
| echo "continue=true" >> $GITHUB_OUTPUT | |
| echo "On \`main\` Branch, Type: \`development\`" | |
| elif [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then | |
| echo "type=development" >> $GITHUB_OUTPUT | |
| echo "continue=true" >> $GITHUB_OUTPUT | |
| echo "On \`develop\` Branch, Type: \`development\`" | |
| elif [[ "${{ github.ref }}" =~ ^refs/heads/releases/ ]]; then | |
| semver_regex='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$' | |
| version=$(echo "${{ github.ref }}" | sed -n -E 's#^refs/heads/releases/##p') | |
| if [[ ! "$version" =~ $semver_regex ]]; then | |
| echo "Not a valid release branch semver. Will Not Continue" | |
| exit 0 | |
| fi | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| echo "type=release" >> $GITHUB_OUTPUT | |
| echo "continue=true" >> $GITHUB_OUTPUT | |
| echo "In \`releases/$version\` Branch, Type: \`release\`" | |
| else | |
| echo "Not Correct Branch. Will Not Continue" | |
| fi | |
| else | |
| echo "Not a Push Event. Will Not Continue" | |
| fi | |
| else | |
| echo "On a Forked Repository. Will Not Continue" | |
| fi | |
| publish_development: | |
| name: Publish (Development) | |
| environment: dockerhub-torrust | |
| needs: context | |
| if: needs.context.outputs.continue == 'true' && needs.context.outputs.type == 'development' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - id: checkout | |
| name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| - id: meta | |
| name: Docker Meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: | | |
| "${{ secrets.DOCKER_HUB_USERNAME }}/${{secrets.DOCKER_HUB_REPOSITORY_NAME }}" | |
| tags: | | |
| type=ref,event=branch | |
| - id: login | |
| name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - id: setup | |
| name: Setup Toolchain | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| file: ./Containerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| target: release | |
| cache-from: type=gha,scope=container-publish-dev | |
| cache-to: type=gha,scope=container-publish-dev,mode=max | |
| publish_release: | |
| name: Publish (Release) | |
| environment: dockerhub-torrust | |
| needs: context | |
| if: needs.context.outputs.continue == 'true' && needs.context.outputs.type == 'release' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - id: checkout | |
| name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| - id: meta | |
| name: Docker Meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: | | |
| "${{ secrets.DOCKER_HUB_USERNAME }}/${{secrets.DOCKER_HUB_REPOSITORY_NAME }}" | |
| tags: | | |
| type=semver,value=${{ needs.context.outputs.version }},pattern={{raw}} | |
| type=semver,value=${{ needs.context.outputs.version }},pattern={{version}} | |
| type=semver,value=${{ needs.context.outputs.version }},pattern=v{{major}} | |
| type=semver,value=${{ needs.context.outputs.version }},pattern={{major}}.{{minor}} | |
| - id: login | |
| name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - id: setup | |
| name: Setup Toolchain | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| file: ./Containerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| target: release | |
| cache-from: type=gha,scope=container-publish-release | |
| cache-to: type=gha,scope=container-publish-release,mode=max |