Update Servers #6
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: Update Servers | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 0' # Weekly on Sunday | |
| workflow_dispatch: | |
| inputs: | |
| force: | |
| description: 'Force build all images' | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has_updates: ${{ steps.update.outputs.has_updates }} | |
| updated_servers: ${{ steps.update.outputs.updated_servers }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: '3.12' | |
| - name: Run update script | |
| id: update | |
| run: | | |
| FORCE_FLAG="" | |
| if [[ "${{ github.event.inputs.force }}" == "true" ]]; then | |
| FORCE_FLAG="--force" | |
| fi | |
| uv run scripts/update_containers.py $FORCE_FLAG | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Commit and push changes | |
| if: steps.update.outputs.has_updates == 'true' | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add container/ | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: update server versions" | |
| git push | |
| else | |
| echo "No changes to commit" | |
| fi | |
| build: | |
| needs: update | |
| if: needs.update.outputs.has_updates == 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| server: ${{ fromJson(needs.update.outputs.updated_servers) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get version | |
| id: get_version | |
| run: | | |
| VERSION=$(grep "ARG VERSION=" container/${{ matrix.server }}/ContainerFile | cut -d'=' -f2) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: container/${{ matrix.server }} | |
| file: container/${{ matrix.server }}/ContainerFile | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository }}/${{ matrix.server }}:${{ steps.get_version.outputs.version }} | |
| ghcr.io/${{ github.repository }}/${{ matrix.server }}:latest |