feat(user): support custom metadata #408
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: Work Branch CI | |
| on: | |
| pull_request: | |
| branches: ["work"] | |
| paths: ["src/**"] | |
| push: | |
| branches: ["work"] | |
| paths: ["src/**"] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| defaults: | |
| run: | |
| working-directory: src/GZCTF | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: src/global.json | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: latest | |
| - name: Install pnpm | |
| run: npm i -g pnpm | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore -c Release | |
| - name: Get current date time | |
| id: datetime | |
| uses: Kaven-Universe/github-action-current-date-time@v1 | |
| with: | |
| format: "YYYY-MM-DDTHH:mm:ssZ" | |
| - name: Prebuild project | |
| run: | | |
| npm i -g pnpm | |
| dotnet build "GZCTF.csproj" -c Release -o build | |
| - name: Publish project | |
| run: | | |
| dotnet publish "GZCTF.csproj" -c Release -o publish/linux/amd64 -r linux-x64 --no-self-contained /p:PublishReadyToRun=true | |
| env: | |
| VITE_APP_BUILD_TIMESTAMP: ${{ steps.datetime.outputs.time }} | |
| VITE_APP_GIT_SHA: ${{ github.sha }} | |
| VITE_APP_GIT_NAME: ${{ github.ref_name }} | |
| - name: Docker setup Buildx | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata action | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| uses: docker/metadata-action@v5 | |
| id: meta | |
| with: | |
| images: ghcr.io/${{ github.repository }}/gzctf | |
| tags: | | |
| type=raw,value=work | |
| - name: Publish image | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./src/GZCTF | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64 | |
| push: true | |
| prune: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Prune old work images | |
| uses: dataaxiom/ghcr-cleanup-action@v1 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| package: gzctf/gzctf | |
| use-regex: true | |
| exclude-tags: "^latest$|^develop$|v\\d+(\\.\\d+){0,2}|^work$" | |
| validate: true | |
| dry-run: false | |
| delete-untagged: true | |
| delete-ghost-images: true | |
| delete-partial-images: true |