doc zen browser #177
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 | |
| on: | |
| push: | |
| branches: [ master ] | |
| concurrency: | |
| group: environment-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| setup_env: | |
| name: ⚙️ Setup environment | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Add SHORT_SHA env property | |
| run: echo "SHORT_SHA=`echo ${GITHUB_SHA::7}`" >> $GITHUB_ENV | |
| - name: Put commit msg in environment | |
| run: | | |
| echo "COMMIT_MSG<<EOF" >> $GITHUB_ENV | |
| echo "${{ github.event.head_commit.message }}" | head -n 1 >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Get branch name (merge) | |
| if: github.event_name != 'pull_request' | |
| shell: bash | |
| run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV | |
| - name: Get branch name (pull request) | |
| if: github.event_name == 'pull_request' | |
| shell: bash | |
| run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV | |
| - name: Set build start in env variable | |
| run: echo "BUILD_START=$(date +%s)" >> $GITHUB_ENV | |
| outputs: | |
| short_sha: ${{ env.SHORT_SHA }} | |
| commit_msg: ${{ env.COMMIT_MSG }} | |
| branch_name: ${{ env.BRANCH_NAME }} | |
| build_start: ${{ env.BUILD_START }} | |
| build_and_publish: | |
| name: Build dlx-docs | |
| needs: setup_env | |
| strategy: | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| runs-on: ubuntu-24.04 | |
| arch: amd64 | |
| - platform: linux/arm64 | |
| runs-on: ubuntu-24.04-arm | |
| arch: arm64 | |
| runs-on: ${{ matrix.runs-on }} | |
| env: | |
| GITHUB_RUN_ID: ${{ github.run_id }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push image | |
| if: success() | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| provenance: false | |
| push: true | |
| file: ./Dockerfile | |
| tags: ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-${{ matrix.arch }} | |
| build_and_publish_server: | |
| name: Build dlx-docs-server | |
| needs: setup_env | |
| strategy: | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| runs-on: ubuntu-24.04 | |
| arch: amd64 | |
| - platform: linux/arm64 | |
| runs-on: ubuntu-24.04-arm | |
| arch: arm64 | |
| runs-on: ${{ matrix.runs-on }} | |
| env: | |
| GITHUB_RUN_ID: ${{ github.run_id }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Go with cache | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: ./server/go.mod | |
| - name: Build GO Server Binary | |
| run: | | |
| cd server/cmd/api && CGO_ENABLED=0 GOARCH=${{ matrix.arch }} go build -ldflags "-s -w -X main.Version=${{ needs.setup_env.outputs.short_sha }}" -o ./api && cd ../../.. | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push server image | |
| if: success() | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| provenance: false | |
| push: true | |
| file: ./server/Dockerfile | |
| tags: ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-${{ matrix.arch }} | |
| create_manifest: | |
| name: 📦 Create Multi-Arch Manifest | |
| runs-on: ubuntu-24.04 | |
| needs: [setup_env, build_and_publish] | |
| env: | |
| GITHUB_RUN_ID: ${{ github.run_id }} | |
| steps: | |
| - name: Login to registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create and push manifest | |
| run: | | |
| docker manifest create ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} \ | |
| --amend ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-amd64 \ | |
| --amend ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-arm64 | |
| docker manifest annotate --arch amd64 --os linux ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-amd64 | |
| docker manifest annotate --arch arm64 --os linux ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-arm64 | |
| docker manifest push ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} | |
| create_manifest_server: | |
| name: 📦 Create Multi-Arch Manifest Server | |
| runs-on: ubuntu-24.04 | |
| needs: [setup_env, build_and_publish_server] | |
| env: | |
| GITHUB_RUN_ID: ${{ github.run_id }} | |
| steps: | |
| - name: Login to registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create and push server manifest | |
| run: | | |
| docker manifest create ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} \ | |
| --amend ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-amd64 \ | |
| --amend ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-arm64 | |
| docker manifest annotate --arch amd64 --os linux ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-amd64 | |
| docker manifest annotate --arch arm64 --os linux ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }}-arm64 | |
| docker manifest push ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} | |
| deploy_image: | |
| name: Deploy dlx-docs | |
| needs: [setup_env, create_manifest, create_manifest_server] | |
| runs-on: ubuntu-24.04 | |
| env: | |
| GITHUB_RUN_ID: ${{ github.run_id }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: imranismail/setup-kustomize@v1 | |
| with: | |
| kustomize-version: "3.5.4" | |
| - name: Set image | |
| working-directory: ./k8s | |
| run: | | |
| kustomize edit set image replaceme=ghcr.io/avengemedia/dlx-docs:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} | |
| kustomize edit set image replaceme-server=ghcr.io/avengemedia/dlx-docs-server:${{ needs.setup_env.outputs.branch_name }}-${{ env.GITHUB_RUN_ID }} | |
| kustomize build . > deployment-k.yaml | |
| - name: Deploy image to k8s cluster | |
| uses: bbedward/kubectl@master | |
| env: | |
| KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} | |
| with: | |
| args: apply -f ./k8s/deployment-k.yaml |