Skip to content

Add Qbit explorer support and container publishing #3

Add Qbit explorer support and container publishing

Add Qbit explorer support and container publishing #3

Workflow file for this run

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:
CI_GCP_PROJECT_ID: ${{ secrets.CI_GCP_PROJECT_ID }}
CI_GCP_SERVICE_ACCOUNT: ${{ secrets.CI_GCP_SERVICE_ACCOUNT }}
CI_GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.CI_GCP_WORKLOAD_IDENTITY_PROVIDER }}
IMAGE_NAME: gcr.io/analog-stage-198105/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
id-token: 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: Authenticate to GCP
id: auth
if: github.event_name != 'pull_request'
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
token_format: access_token
workload_identity_provider: ${{ env.CI_GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.CI_GCP_SERVICE_ACCOUNT }}
- name: Login to GCR
if: github.event_name != 'pull_request'
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: gcr.io
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_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
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 }}