Skip to content

Build & Publish Image #783

Build & Publish Image

Build & Publish Image #783

Workflow file for this run

name: Build & Publish Image
on:
push:
branches: ["develop", "ci-test*"]
tags: ["v*"]
paths: ["src/GZCTF/**"]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/GZCTF
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
- uses: actions/setup-node@v3
with:
node-version: 20
- 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
dotnet publish "GZCTF.csproj" -c Release -o publish/linux/arm64 -r linux-arm64 --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 QEMU
uses: docker/setup-qemu-action@v2
- name: Docker setup Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
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
id: meta
with:
images: |
ghcr.io/${{ github.repository_owner }}/gzctf/gzctf
gztime/gzctf
tags: |
latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=ref,event=branch
type=semver,pattern={{raw}}
type=sha,enable=true,priority=100,prefix=,suffix=,format=short
- name: Publish images
uses: docker/build-push-action@v4
with:
context: ./src/GZCTF
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
push: true
- name: Prune old packages
uses: vlaurin/[email protected]
with:
dry-run: false
token: ${{ secrets.PACKAGE_TOKEN }}
container: "gzctf/gzctf"
keep-tags-regexes: ^v(.)*
prune-tags-regexes: ^[0-9a-f]{6,40}
keep-tags: |
latest
main
develop
keep-last: 20
prune-untagged: false