Add Qbit explorer support and container publishing #1
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: Build and publish Docker image | |
| on: | |
| pull_request: | |
| paths: | |
| - ".github/workflows/docker-image.yml" | |
| - "app.js" | |
| - "app/**" | |
| - "bin/**" | |
| - "routes/**" | |
| - "public/**" | |
| - "test/**" | |
| - "views/**" | |
| - ".dockerignore" | |
| - "Dockerfile" | |
| - "docker-compose.qbit.yml" | |
| - "npm-shrinkwrap.json" | |
| - "package.json" | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| IMAGE_NAME: ghcr.io/luxorlabs/luxor-qbit-explorer | |
| jobs: | |
| test-build-publish: | |
| name: Test, build, and publish image | |
| runs-on: tenki-standard-large-plus-16c-32g | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Repository checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: npm-shrinkwrap.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: | | |
| npm test | |
| npm run test:qbit | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Login to GitHub Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate image metadata | |
| id: meta | |
| shell: bash | |
| run: | | |
| short_sha="${GITHUB_SHA:0:7}" | |
| created="$(date -u +%Y-%m-%dT%H:%M:%SZ)" | |
| { | |
| echo "created=${created}" | |
| echo "tags<<EOF" | |
| echo "${IMAGE_NAME}:sha-${short_sha}" | |
| if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then | |
| echo "${IMAGE_NAME}:latest" | |
| fi | |
| if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then | |
| echo "${IMAGE_NAME}:${GITHUB_REF_NAME}" | |
| echo "${IMAGE_NAME}:${GITHUB_REF_NAME#v}" | |
| fi | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Build and publish image | |
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| labels: | | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.created=${{ steps.meta.outputs.created }} |