Skip to content

Merge branch 'fix/ridden-roads-client-cache' #180

Merge branch 'fix/ridden-roads-client-cache'

Merge branch 'fix/ridden-roads-client-cache' #180

name: Build and publish Docker image
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run lint
run: npm run lint
- name: Run tests
run: npm test
- name: Build
run: npm run build
build-and-push:
needs: test
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from package.json
id: version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Tag Repository
run: |
NEW_TAG="v${{ steps.version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if git rev-parse "$NEW_TAG" >/dev/null 2>&1; then
echo "Tag $NEW_TAG already exists locally."
else
echo "Creating local tag $NEW_TAG"
git tag "$NEW_TAG"
fi
if git ls-remote --tags origin | grep -q "refs/tags/$NEW_TAG"; then
echo "Tag $NEW_TAG already exists on remote origin."
else
echo "Pushing tag $NEW_TAG to remote"
git push origin "$NEW_TAG"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
docker.io/bigtimber/street-sweep:latest
docker.io/bigtimber/street-sweep:v${{ steps.version.outputs.version }}
build-args: |
VERSION=v${{ steps.version.outputs.version }}
- name: Image info
run: docker manifest inspect docker.io/bigtimber/street-sweep:latest || true