Update ci.yml #69
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: CI Workflow | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set Docker image name | |
id: docker_image_name | |
run: echo "migupele/java_school_online_store_frontend" | |
- uses: actions/cache@v3 | |
env: | |
cache-name: ${{ runner.os }}-build-${{ github.job }} | |
with: | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Cache Docker layers | |
uses: docker/layer-cache@v3 | |
with: | |
key: ${{ runner.os }}-docker-${{ hashFiles('./Dockerfile') }} | |
- name: Build Docker image (using cache) | |
run: | | |
docker build --cache-from ${{ steps.docker_layer_cache.outputs.layer_cache }} -t ${{ steps.docker_image_name.outputs.image_name }} . | |
- uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v1 | |
with: | |
images: migupele/java_school_online_store_frontend | |
- uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: npm install and npm run CI commands | |
run: | | |
npm i | |
npm run build |