chore(deps): update npm (runtime) (#7) #12
This file contains 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: | |
push: | |
branches: | |
- main | |
- develop | |
tags: | |
- "*.*.*" | |
pull_request: | |
branches: | |
- main | |
- develop | |
types: | |
- labeled | |
env: | |
REGISTRY_IMAGE: governify/registry | |
GHCR_IMAGE: governify/registry | |
PR_ID: ${{ github.event.pull_request.number }} | |
TAG: ${{ github.ref_name }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [22.x] | |
steps: | |
- name: Checkout repository β¬οΈ | |
uses: actions/checkout@v4 | |
- name: Set up Node.js ${{ matrix.node-version }} π¦π οΈ | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies π¦β¬οΈ | |
run: npm install | |
- name: Start the server π | |
run: npm start & | |
# - name: Check server is running π | |
# run: curl -f http://localhost:5800/docs || exit 1 | |
test: | |
name: Lint, test and coverage to coveralls π§ͺ | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
node-version: [22.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npm run test | |
env: | |
CI: true | |
- name: Generate coverage report | |
run: npm run coverage | |
env: | |
CI: true | |
- name: Coverage to Coveralls | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
env: | |
CI: true | |
docker: | |
runs-on: ubuntu-latest | |
needs: test | |
if: ((github.event.pull_request && github.event.label.name == 'π³ Dockerize') || github.event_name == 'push') && startsWith(github.repository, 'governify/') | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Checkout β¬οΈ | |
uses: actions/checkout@v4.2.2 | |
with: | |
show-progress: false | |
- name: Configure QEMU βοΈ | |
uses: docker/setup-qemu-action@v3.2.0 | |
- name: Configure Docker Buildx βοΈ | |
uses: docker/setup-buildx-action@v3.7.1 | |
- name: Login to DockerHub π | |
uses: docker/login-action@v3.3.0 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry π | |
uses: docker/login-action@v3.3.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v6.10.0 | |
with: | |
context: . | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: | | |
${{ startsWith(github.ref, 'refs/tags/') && format('{0}:{1}', env.REGISTRY_IMAGE, env.TAG) || '' }} | |
${{ github.ref == 'refs/heads/main' && format('{0}:latest', env.REGISTRY_IMAGE) || '' }} | |
${{ github.ref == 'refs/heads/develop' && github.event_name == 'push' && format('{0}:develop', env.REGISTRY_IMAGE) || '' }} | |
${{ github.event_name == 'pull_request' && format('{0}:PR.{1}', env.REGISTRY_IMAGE, env.PR_ID) || '' }} | |
- name: Build and Push Ghcr Image | |
uses: docker/build-push-action@v6.10.0 | |
with: | |
context: . | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: | | |
${{ startsWith(github.ref, 'refs/tags/') && format('ghcr.io/{0}:{1}', env.GHCR_IMAGE, env.TAG) || '' }} | |
${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}:latest', env.GHCR_IMAGE) || '' }} | |
${{ github.ref == 'refs/heads/develop' && github.event_name == 'push' && format('ghcr.io/{0}:develop', env.GHCR_IMAGE) || '' }} | |
${{ github.event_name == 'pull_request' && format('ghcr.io/{0}:PR.{1}', env.GHCR_IMAGE, env.PR_ID) || '' }} |