Skip to content

fix: specific items could not load the details anymore due to incorre… #237

fix: specific items could not load the details anymore due to incorre…

fix: specific items could not load the details anymore due to incorre… #237

Workflow file for this run

name: CI
on: push
env:
IMAGE_NAME: ${{ github.repository }}
NODE_VERSION: '20.12.2'
jobs:
check-image:
name: Check for existing image
runs-on: 'ubuntu-latest'
outputs:
exists: ${{ steps.request-image-info.outputs.exists }}
steps:
- id: request-image-info
run: |
response_code=$(curl -s -o /dev/null -I -L -w "%{http_code}" https://hub.docker.com/v2/repositories/${{ env.IMAGE_NAME }}/tags/${{ github.sha }}/)
echo $response_code
if [ $response_code -eq 200 ]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "::notice ::Found existing image ${{ github.repository }}:${{ github.sha }}"
elif [ $response_code -eq 404 ]; then
echo "exists=false" >> $GITHUB_OUTPUT
else
echo "::error ::Got unexpected HTTP code $response_code"
exit 22
fi
build-image:
name: Build image
runs-on: 'ubuntu-latest'
needs: check-image
if: ${{ needs.check-image.outputs.exists == 'false' }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: docker/login-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: ./node_modules
key: modules-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build the project
run: npm run build
- name: Build Docker image
run: docker build --tag ${{ github.repository }}:${{ github.sha }} .
- name: Publish to DockerHub
run: |
docker push ${{ github.repository }}:${{ github.sha }}
echo "::notice ::Published as ${{ github.repository }}:${{ github.sha }}"
tag-image-ref:
name: Publish image
runs-on: 'ubuntu-latest'
needs: build-image
if: ${{ success() || needs.build-image.result == 'skipped' }}
steps:
- uses: docker/login-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: rlespinasse/github-slug-action@v4
- name: Pull Docker image
run: docker pull ${{ github.repository }}:${{ github.sha }}
- name: Tag Docker image
run: docker tag ${{ github.repository }}:${{ github.sha }} ${{ github.repository }}:${{ env.GITHUB_REF_SLUG }}
- name: Publish to DockerHub
run: |
docker push ${{ github.repository }}:${{ env.GITHUB_REF_SLUG }}
echo "::notice ::Published as ${{ github.repository }}:${{ env.GITHUB_REF_SLUG }}"
lint:
name: Lint
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: ./node_modules
key: modules-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Lint
run: npm run lint
cypress-tests:
name: Cypress tests
runs-on: ubuntu-latest
needs: build-image
if: ${{ success() || needs.build-image.result == 'skipped' }}
services:
frontend:
image: ${{ github.repository }}:${{ github.sha }}
env:
EDU_SHARING_API_URL: https://repository.staging.openeduhub.net/edu-sharing/rest
ports:
- 8080:80
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cypress run
uses: cypress-io/github-action@v4
env:
CYPRESS_baseUrl: http://localhost:8080
# We cannot guarantee that the given Edu-Sharing instance allows localhost with
# 'Access-Control-Allow-Origin'.
CYPRESS_chromeWebSecurity: false
with:
working-directory: e2e-cypress
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: e2e-cypress/cypress/screenshots
build-web-components:
name: Build web components
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: ./node_modules
key: modules-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build web components
run: npm run build:web-components
- uses: actions/upload-artifact@v4
with:
name: web-components
path: dist/web-components