build #613
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: build | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| merge_group: | |
| types: | |
| - checks_requested | |
| release: | |
| types: | |
| - published | |
| jobs: | |
| linting: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Run isort | |
| uses: isort/isort-action@v1.1.1 | |
| id: isort | |
| with: | |
| configuration: --profile black --check-only --diff -l 125 --verbose | |
| - name: isort summary | |
| env: | |
| ISORT_SUMMARY: ${{ steps.isort.outputs.isort-result }} | |
| run: | | |
| echo "\`\`\`python" >> $GITHUB_STEP_SUMMARY | |
| echo "$ISORT_SUMMARY" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| - name: Run black | |
| uses: psf/black@26.1.0 | |
| with: | |
| options: "-l 125 --check --diff --verbose" | |
| test: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Test with pytest | |
| run: pytest --cov bridger | |
| build: | |
| runs-on: self-hosted | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract branch name | |
| id: extract_branch | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/heads/gh-readonly-queue/* ]]; then | |
| BRANCH_NAME=$(echo "${GITHUB_REF}" | sed 's#refs/heads/gh-readonly-queue/[^/]*/##') | |
| elif [[ "${GITHUB_REF}" == refs/heads/* ]]; then | |
| BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
| elif [[ "${GITHUB_REF}" == refs/pull/* ]]; then | |
| BRANCH_NAME=$(echo ${GITHUB_REF} | sed 's#refs/pull/##; s#/merge##') | |
| elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| BRANCH_NAME=${GITHUB_REF#refs/tags/} | |
| else | |
| BRANCH_NAME=${GITHUB_REF} | |
| fi | |
| echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV | |
| echo "branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT | |
| - name: Set image tags | |
| id: set_tags | |
| run: | | |
| TAGS="ghcr.io/${{ github.repository }}:${{ github.sha }} ghcr.io/${{ github.repository }}:$BRANCH_NAME" | |
| if [ "$BRANCH_NAME" == "main" ]; then | |
| TAGS="$TAGS ghcr.io/${{ github.repository }}:latest" | |
| fi | |
| echo "tags=$TAGS" >> "$GITHUB_OUTPUT" | |
| - name: Build bridger image | |
| id: build_image | |
| uses: redhat-actions/buildah-build@v2.13 | |
| with: | |
| image: ghcr.io/${{ github.repository }} | |
| platforms: linux/amd64 | |
| tags: ${{ steps.set_tags.outputs.tags }} | |
| containerfiles: ./Containerfile | |
| build-args: | | |
| release=bridger@${{ steps.extract_branch.outputs.branch_name }} | |
| - name: Build simple-proxy image | |
| id: build_simple_proxy | |
| uses: redhat-actions/buildah-build@v2.13 | |
| with: | |
| image: ghcr.io/${{ github.repository_owner }}/simple-proxy | |
| platforms: linux/amd64,linux/arm64 | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/simple-proxy:${{ github.sha }} | |
| ghcr.io/${{ github.repository_owner }}/simple-proxy:latest | |
| containerfiles: ./config/docker/simple-proxy/Containerfile | |
| - name: Push image | |
| uses: redhat-actions/push-to-registry@v2 | |
| with: | |
| tags: ${{ steps.build_image.outputs.tags }} | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push simple-proxy manifests | |
| uses: redhat-actions/push-to-registry@v2 | |
| with: | |
| tags: ${{ steps.build_simple_proxy.outputs.tags }} | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| deploy: | |
| runs-on: self-hosted | |
| needs: | |
| - build | |
| - test | |
| - linting | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Create Sentry release with shell | |
| run: | | |
| RELEASE="${SENTRY_PROJECT}@${{ github.event.release.tag_name }}" | |
| sentry-cli releases new $RELEASE | |
| sentry-cli releases set-commits --auto --ignore-missing $RELEASE | |
| sentry-cli deploys new -e production -r $RELEASE | |
| sentry-cli releases finalize $RELEASE | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| SENTRY_ORG: shinncloud | |
| SENTRY_PROJECT: bridger | |
| - name: Deploy Quadlets | |
| run: config/deploy.sh | |
| env: | |
| IMAGE: ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} | |
| - name: Notify Discord | |
| uses: tsickert/discord-webhook@v7.0.0 | |
| with: | |
| webhook-url: ${{ secrets.DISCORD_WEBHOOK }} | |
| username: "Bridger" | |
| flags: 4 | |
| content: | | |
| Deployed Bridger version: ${{ github.event.release.tag_name }} | |
| ${{ github.event.release.body }} |