diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index edc8624..f14959a 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -20,39 +20,20 @@ env: GKE_CLUSTER_DEV: nmrxiv-dev GKE_ZONE: europe-west3-a DEPLOYMENT_NAME: nodejs-nmrxiv-nodejs-microservice - REPOSITORY_NAME_DEV: nmrxiv-dev - IMAGE: nmrxiv-nodejs-microservice + DOCKER_HUB_USERNAME : ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }} + REPOSITORY_NAME: nodejs-microservice + REPOSITORY_NAMESPACE: nfdi4chem jobs: - test: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.x] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - name: 'Create .env file' - run: | - touch .env - cp .env.example .env - - run: npm ci - - run: npm run build --if-present - - name: Install Playwright - run: npx playwright install --with-deps - - name: Run test - run: npm test + e2etest: + uses: NFDI4Chem/nmrxiv-nodejs-microservice/.github/workflows/e2e.yml@development setup-build-publish-deploy-dev: name: Deploy to dev if: github.ref == 'refs/heads/development' runs-on: ubuntu-latest - needs: test + needs: e2etest steps: - name: Checkout uses: actions/checkout@v2 @@ -69,7 +50,7 @@ jobs: run: |- gcloud auth configure-docker europe-west3-docker.pkg.dev - # Get the GKE credentials so we can deploy to the cluster + # Get the GKE credentials - name: Get GKE credentials uses: google-github-actions/get-gke-credentials@v0.3.0 with: @@ -77,15 +58,25 @@ jobs: location: ${{ env.GKE_ZONE }} credentials: ${{ secrets.GKE_SA_KEY }} - # Build the Docker image - - name: Build docker image - run: |- - docker build --tag europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_DEV/$IMAGE:latest . + # Login to Docker Hub + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ env.DOCKER_HUB_USERNAME }} + password: ${{ env.DOCKER_HUB_PASSWORD }} - # Push the Docker image to Google Artifact Registry - - name: Publish Image to Google Artifact Registry - run: |- - docker push "europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_DEV/$IMAGE:latest" + # Build and push image to Docker Hub + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + build-args: | + RELEASE_VERSION=dev-latest + tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-latest + username: ${{ env.DOCKER_HUB_USERNAME }} + password: ${{ env.DOCKER_HUB_PASSWORD }} # Deploy the latest Docker image to the GKE cluster - name: Deploy diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..e14342c --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,29 @@ +name: e2e tests + +on: + workflow_call: + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - name: 'Create .env file' + run: | + touch .env + cp .env.example .env + - run: npm ci + - run: npm run build --if-present + - name: Install Playwright + run: npx playwright install --with-deps + - name: Run test + run: npm test \ No newline at end of file