Add .dockerignore and update Docker configurations for Playwright ins… #14
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: [ "v*" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| workflow_dispatch: | |
| inputs: | |
| build_base_image: | |
| description: 'Build base image only' | |
| required: true | |
| default: 'false' | |
| type: choice | |
| options: | |
| - 'true' | |
| - 'false' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24' | |
| - name: Verify Go Version | |
| run: go version | |
| - name: Download Dependencies | |
| run: go mod download | |
| - name: Run Tests | |
| run: go test -v ./... | |
| - name: Build Binary | |
| run: | | |
| mkdir -p build | |
| GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -ldflags="-w -s -extldflags '-static'" -o build/inkforge ./cmd/inkforge | |
| base-image-build: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' && inputs.build_base_image == 'true' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-docker-action@v3 | |
| with: | |
| version: v25.0.4 | |
| - name: Login to Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: registry.yygu.cn | |
| username: ${{ secrets.REGISTRY_USER }} | |
| password: ${{ secrets.REGISTRY_PASS }} | |
| - name: Extract metadata for base image | |
| id: base-meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: registry.yygu.cn/skills/inkforge | |
| tags: | | |
| type=raw,value=base | |
| - name: Build and push base image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./deployments/base.Dockerfile | |
| tags: ${{ steps.base-meta.outputs.tags }} | |
| labels: ${{ steps.base-meta.outputs.labels }} | |
| push: true | |
| - name: Logout from Registry | |
| run: docker logout registry.yygu.cn | |
| docker-build-and-push: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && inputs.build_base_image == 'false') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-docker-action@v3 | |
| with: | |
| version: v25.0.4 | |
| - name: Login to Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: registry.yygu.cn | |
| username: ${{ secrets.REGISTRY_USER }} | |
| password: ${{ secrets.REGISTRY_PASS }} | |
| - name: Extract metadata for release image | |
| id: release-meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: registry.yygu.cn/skills/inkforge | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=sha,prefix={{branch}}- | |
| - name: Build and push release image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./deployments/Dockerfile | |
| tags: ${{ steps.release-meta.outputs.tags }} | |
| labels: ${{ steps.release-meta.outputs.labels }} | |
| push: true | |
| - name: Logout from Registry | |
| run: docker logout registry.yygu.cn |