-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: build and push docker image to Docker Hub
refactoring of test files
- Loading branch information
1 parent
5854182
commit 85004c2
Showing
2 changed files
with
55 additions
and
35 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,23 +50,33 @@ 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/[email protected] | ||
with: | ||
cluster_name: ${{ env.GKE_CLUSTER_DEV }} | ||
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 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |