diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e90a346..51dd7fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,10 +28,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -# Set Workflow-level environment variables -env: - PROJECT: demoapp-frontend - jobs: unit-test: # Run job when not triggered by a merge @@ -40,6 +36,20 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout + + # Cache NPM dependencies + - name: Cache NPM dependencies + id: cache + uses: actions/cache@v3 # https://github.com/marketplace/actions/cache#using-a-combination-of-restore-and-save-actions + with: + path: | + node_modules + key: npm-${{ hashFiles('package-lock.json') }} + + # Install NPM dependencies + - name: Install NPM dependencies + run: npm ci + - name: Run tests run: npm run test @@ -86,7 +96,7 @@ jobs: # Set Complete Container Image URL - name: Set CONTAINER_IMAGE_URL run: | - echo "CONTAINER_IMAGE_URL=${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.PROJECT }}:${{ env.CI_ACTION_REF_NAME }}" >> $GITHUB_ENV + echo "CONTAINER_IMAGE_URL=${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.CI_REPOSITORY_NAME }}:${{ env.CI_ACTION_REF_NAME }}" >> $GITHUB_ENV - name: Checkout repository uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout @@ -154,7 +164,7 @@ jobs: # Set Complete Container Image URL - name: Set CONTAINER_IMAGE_URL run: | - echo "CONTAINER_IMAGE_URL=${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.PROJECT }}:${{ env.CI_ACTION_REF_NAME }}" >> $GITHUB_ENV + echo "CONTAINER_IMAGE_URL=${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.CI_REPOSITORY_NAME }}:${{ env.CI_ACTION_REF_NAME }}" >> $GITHUB_ENV - name: Login to DockerHub uses: docker/login-action@v3 # https://github.com/marketplace/actions/docker-login @@ -224,7 +234,7 @@ jobs: # Set Complete Container Image URL - name: Set CONTAINER_IMAGE_URL run: | - echo "CONTAINER_IMAGE_URL=${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.PROJECT }}:${{ env.CI_ACTION_REF_NAME }}" >> $GITHUB_ENV + echo "CONTAINER_IMAGE_URL=${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.CI_REPOSITORY_NAME }}:${{ env.CI_ACTION_REF_NAME }}" >> $GITHUB_ENV - name: Checkout repository uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout