From 159015d881eb063fbadf9046224c728de05a732a Mon Sep 17 00:00:00 2001 From: GZTime Date: Sat, 27 Aug 2022 02:27:12 +0800 Subject: [PATCH] update: ci update: ci update: name of ci workflow update: ci workflow fix: action version fix: platform fix: QEMU for arm64 update: Dockerfile fix: Dockerfile --- .github/workflows/ci.amd64.yml | 81 ++++++++++++++++++++++++++++++++ .github/workflows/ci.arm64.yml | 84 ++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 53 --------------------- Dockerfile | 3 ++ 4 files changed, 168 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/ci.amd64.yml create mode 100644 .github/workflows/ci.arm64.yml delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.amd64.yml b/.github/workflows/ci.amd64.yml new file mode 100644 index 000000000..e87e0fb8e --- /dev/null +++ b/.github/workflows/ci.amd64.yml @@ -0,0 +1,81 @@ +name: Image for amd64 + +on: + push: + branches: [ "develop", "ci-test*" ] + tags: [ "v*" ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Get Time + id: time + uses: nanzm/get-time-action@v1.1 + with: + timeZone: 8 + + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v2.0.0 + + - name: Login to Docker Hub + uses: docker/login-action@v2.0.0 + with: + username: gztime + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker Metadata action + uses: docker/metadata-action@v4.0.1 + id: meta + with: + # List of Docker images to use as base name for tags + images: | + ghcr.io/${{ github.repository_owner }}/gzctf/gzctf + gztime/gzctf + # List of tags as key-value pair attributes + tags: | + latest + type=ref,event=branch + type=semver,pattern={{raw}} + type=sha,enable=true,priority=100,prefix=,suffix=,format=short + + - name: Build and push + uses: docker/build-push-action@v3 + with: + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64 + cache-from: type=gha + cache-to: type=gha + build-args: | + TIMESTAMP=${{ steps.time.outputs.time }} + GIT_SHA=${{ github.sha }} + GIT_NAME=${{ github.ref_name }} + push: true + + - name: Prune old packages + uses: vlaurin/action-ghcr-prune@v0.4.0 + with: + token: ${{ secrets.PACKAGE_TOKEN }} + container: "gzctf/gzctf" + dry-run: false + tag-regex: ^[0-9a-f]{6,40} + keep-tags: | + latest + main + develop + keep-tags-regexes: + ^v(.)* + keep-last: 5 + untagged: true diff --git a/.github/workflows/ci.arm64.yml b/.github/workflows/ci.arm64.yml new file mode 100644 index 000000000..93164eedf --- /dev/null +++ b/.github/workflows/ci.arm64.yml @@ -0,0 +1,84 @@ +name: Image for arm64 + +on: + push: + branches: [ "develop", "ci-test*" ] + tags: [ "v*" ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Get Time + id: time + uses: nanzm/get-time-action@v1.1 + with: + timeZone: 8 + + - name: Docker Setup QEMU + uses: docker/setup-qemu-action@v2.0.0 + + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v2.0.0 + + - name: Login to Docker Hub + uses: docker/login-action@v2.0.0 + with: + username: gztime + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker Metadata action + uses: docker/metadata-action@v4.0.1 + id: meta + with: + # List of Docker images to use as base name for tags + images: | + ghcr.io/${{ github.repository_owner }}/gzctf/gzctf + gztime/gzctf + # List of tags as key-value pair attributes + tags: | + latest + type=ref,event=branch + type=semver,pattern={{raw}} + type=sha,enable=true,priority=100,prefix=,suffix=,format=short + + - name: Build and push + uses: docker/build-push-action@v3 + with: + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/arm64 + cache-from: type=gha + cache-to: type=gha + build-args: | + TIMESTAMP=${{ steps.time.outputs.time }} + GIT_SHA=${{ github.sha }} + GIT_NAME=${{ github.ref_name }} + push: true + + - name: Prune old packages + uses: vlaurin/action-ghcr-prune@v0.4.0 + with: + token: ${{ secrets.PACKAGE_TOKEN }} + container: "gzctf/gzctf" + dry-run: false + tag-regex: ^[0-9a-f]{6,40} + keep-tags: | + latest + main + develop + keep-tags-regexes: + ^v(.)* + keep-last: 5 + untagged: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index f77bd1a6b..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Build & Publish Image - -on: - push: - branches: [ "develop" ] - tags: [ "v*" ] - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Get Time - id: time - uses: nanzm/get-time-action@v1.1 - with: - timeZone: 8 - - - name: Build and publish Docker Image to GitHub Packages Registry - id: publish - uses: matootie/github-docker@v3.1.0 - with: - accessToken: ${{ github.token }} - buildArgs: | - TIMESTAMP=${{ steps.time.outputs.time }} - GIT_SHA=${{ github.sha }} - GIT_NAME=${{ github.ref_name }} - tag: | - latest - ${{ github.ref_name }} - ${{ github.sha }} - - - name: Prune old packages - uses: vlaurin/action-ghcr-prune@v0.4.0 - with: - token: ${{ secrets.PACKAGE_TOKEN }} - container: "gzctf/gzctf" - dry-run: false - tag-regex: ^[0-9a-f]{40} - keep-tags: | - latest - main - develop - keep-tags-regexes: - ^v(.)* - keep-last: 5 - untagged: true - - - name: Print full Image URL - run: echo ${{ steps.publish.outputs.imageURL }}:${{ github.sha }} diff --git a/Dockerfile b/Dockerfile index f41e707a5..694a66495 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,9 @@ RUN apt update && \ apt install -y build-essential nodejs libgdiplus libc6-dev COPY ["GZCTF", "/src/GZCTF/"] +WORKDIR "/src/GZCTF/ClientApp" +RUN npm install --verbose + WORKDIR "/src/GZCTF" RUN dotnet restore "CTFServer.csproj" RUN dotnet build "CTFServer.csproj" -c Release -o /app/build --no-restore