Install packages, actions updates #1
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 web container | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'web/**' | |
- '.github/workflows/web.yml' | |
pull_request: | |
branches: | |
- main | |
paths: | |
- 'web/**' | |
- '.github/workflows/web.yml' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./web | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npm run test | |
build: | |
needs: test | |
if: github.ref == 'refs/heads/main' | |
env: | |
IMAGE: ghcr.io/openinframap/web | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./web | |
file: ./web/Dockerfile.prod | |
push: true | |
tags: | | |
${{ env.IMAGE }}:${{ github.sha }}-${{ github.run_number }} |