Merge pull request #595 from asciimoo/dependabot/npm_and_yarn/npm-dep… #836
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: Publish Docker Image | |
| on: | |
| pull_request: | |
| paths: | |
| - .dockerignore | |
| - .github/workflows/docker-publish.yml | |
| - .github/workflows/docker-release.yml | |
| - compose.yml | |
| - docker-bake.hcl | |
| - Dockerfile | |
| - go.mod | |
| - go.sum | |
| - '**/*.go' | |
| - package.json | |
| - package-lock.json | |
| - webui/app/** | |
| - webui/components/** | |
| push: | |
| branches: | |
| - master | |
| concurrency: | |
| group: docker-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository_owner }}/hister | |
| CACHE_IMAGE: ghcr.io/${{ github.repository_owner }}/hister:buildcache | |
| CACHE_SCOPE: hister-release | |
| jobs: | |
| build: | |
| name: Build Docker images | |
| if: >- | |
| github.event_name != 'pull_request' || | |
| github.event.pull_request.author_association == 'OWNER' || | |
| github.event.pull_request.author_association == 'COLLABORATOR' || | |
| github.actor_id == '49699333' || | |
| github.actor_id == '41898282' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Set up QEMU | |
| if: github.event_name != 'pull_request' | |
| uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 | |
| with: | |
| platforms: arm64 | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 | |
| - name: Validate Compose configuration | |
| run: docker compose config --quiet | |
| - name: Restore Docker cache mounts | |
| id: cache-mounts | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ runner.temp }}/buildkit-cache | |
| key: >- | |
| buildkit-mounts-${{ runner.os }}-${{ | |
| hashFiles('Dockerfile', 'go.sum', 'package-lock.json') }} | |
| restore-keys: | | |
| buildkit-mounts-${{ runner.os }}- | |
| - name: Inject Docker cache mounts | |
| uses: reproducible-containers/buildkit-cache-dance@5422eac04292c961a382e0f584ea0f03ad9da723 # v3.4.0 | |
| with: | |
| builder: ${{ steps.buildx.outputs.name }} | |
| cache-dir: ${{ runner.temp }}/buildkit-cache | |
| scratch-dir: ${{ runner.temp }}/buildkit-cache-scratch | |
| dockerfile: Dockerfile | |
| skip-extraction: ${{ steps.cache-mounts.outputs.cache-hit }} | |
| - name: Log in to GHCR | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract release metadata | |
| if: github.event_name != 'pull_request' | |
| id: meta-release | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| bake-target: release | |
| flavor: | | |
| latest=false | |
| tags: | | |
| type=ref,event=branch | |
| type=sha | |
| - name: Extract root metadata | |
| if: github.event_name != 'pull_request' | |
| id: meta-root | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| bake-target: root | |
| flavor: | | |
| latest=false | |
| suffix=-root,onlatest=true | |
| tags: | | |
| type=ref,event=branch | |
| type=sha | |
| - name: Extract debug metadata | |
| if: github.event_name != 'pull_request' | |
| id: meta-debug | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| bake-target: debug | |
| flavor: | | |
| latest=false | |
| suffix=-debug,onlatest=true | |
| tags: | | |
| type=ref,event=branch | |
| type=sha | |
| - name: Validate Docker images | |
| if: github.event_name == 'pull_request' | |
| uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0 | |
| with: | |
| source: . | |
| files: ./docker-bake.hcl | |
| targets: images | |
| set: | | |
| *.platform=linux/amd64 | |
| *.cache-from=type=gha,scope=${{ env.CACHE_SCOPE }} | |
| *.cache-from+=type=registry,ref=${{ env.CACHE_IMAGE }} | |
| release.tags=hister:ci | |
| release.output=type=docker | |
| release.cache-to=type=gha,mode=max,scope=${{ env.CACHE_SCOPE }},ignore-error=true | |
| - name: Smoke test Compose service | |
| if: github.event_name == 'pull_request' | |
| env: | |
| HISTER_IMAGE: hister:ci | |
| run: | | |
| docker compose up --detach --no-build | |
| for _ in {1..30}; do | |
| if curl --fail --silent --max-time 2 \ | |
| http://127.0.0.1:4433/ >/dev/null; then | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| docker compose logs | |
| exit 1 | |
| - name: Stop Compose service | |
| if: always() && github.event_name == 'pull_request' | |
| env: | |
| HISTER_IMAGE: hister:ci | |
| run: docker compose down --volumes | |
| - name: Build and push Docker images | |
| if: github.ref == 'refs/heads/master' | |
| uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0 | |
| with: | |
| source: . | |
| files: | | |
| ./docker-bake.hcl | |
| cwd://${{ steps.meta-release.outputs.bake-file }} | |
| cwd://${{ steps.meta-root.outputs.bake-file }} | |
| cwd://${{ steps.meta-debug.outputs.bake-file }} | |
| targets: images | |
| push: true | |
| set: | | |
| *.platform=linux/amd64 | |
| *.platform+=linux/arm64 | |
| *.cache-from=type=gha,scope=${{ env.CACHE_SCOPE }} | |
| *.cache-from+=type=registry,ref=${{ env.CACHE_IMAGE }} | |
| *.attest=type=provenance,mode=max | |
| *.attest+=type=sbom | |
| release.cache-to=type=gha,mode=max,scope=${{ env.CACHE_SCOPE }},ignore-error=true | |
| release.cache-to+=type=registry,ref=${{ env.CACHE_IMAGE }},mode=max |