Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/NFDI4Chem/nmrxiv into prod-…
Browse files Browse the repository at this point in the history
…helm-deploy
  • Loading branch information
NishaSharma14 committed Nov 10, 2023
2 parents 72c29eb + 4236d59 commit 8aed0de
Show file tree
Hide file tree
Showing 122 changed files with 9,374 additions and 1,865 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Docs Deployment - GitHub pages
on:
workflow_dispatch: {}
push:
branches:
- development
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- run: npm ci
- name: Build
run: npm run docs:build
- uses: actions/configure-pages@v2
- uses: actions/upload-pages-artifact@v1
with:
path: docs/.vitepress/dist
- name: Deploy
id: deployment
uses: actions/deploy-pages@v2.0.2
145 changes: 145 additions & 0 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
name : Deploy to Dev

on:
Expand All @@ -7,6 +8,21 @@ on:
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: nmrxiv-dev
=======
<<<<<<< HEAD:.github/workflows/prod-build.yml
name : Setup, Build and Publish to Production
=======
name : Setup, Build and Publish to Dev
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd:.github/workflows/dev-build.yml

on:
push:
branches: [prod-helm-deploy]

env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: nmrxiv-prod
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd
GKE_ZONE: europe-west3-a
DEPLOYMENT_NAME: nmrxiv-nmrxiv-app
SCHEDULER_DEPLOYMENT_NAME: nmrxiv-scheduler
Expand All @@ -15,6 +31,7 @@ env:
DOCKER_HUB_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }}
REPOSITORY_NAME: nmrxiv
REPOSITORY_NAMESPACE: nfdi4chem
<<<<<<< HEAD

jobs:
php-unit-test:
Expand All @@ -24,6 +41,79 @@ jobs:
name: Build & deploy to development
runs-on: ubuntu-latest
needs: php-unit-test
=======
<<<<<<< HEAD:.github/workflows/prod-build.yml

=======
DEV_URL: https://dev.nmrxiv.org
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd:.github/workflows/dev-build.yml

jobs:
# php-unit-test:
# uses: NFDI4Chem/nmrxiv/.github/workflows/test.yml@development

php-unit-test:
name: Run test
runs-on: ubuntu-latest
container:
image: kirschbaumdevelopment/laravel-test-runner:8.2

services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: nmrxiv
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Install composer dependencies
run: |
composer install --ignore-platform-reqs
- name: Prepare Laravel Application
run: |
php -r "file_exists('.env') || copy('.env.ci.test', '.env');"
echo AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID_DEV }} >> .env
echo AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} >> .env
echo MEILISEARCH_KEY=${{ secrets.MEILISEARCH_KEY_DEV }} >> .env
echo MEILISEARCH_PUBLICKEY=${{ secrets.MEILISEARCH_PUBLICKEY_DEV }} >> .env
echo TWITTER_CLIENT_ID=${{ secrets.TWITTER_CLIENT_ID_DEV }} >> .env
echo TWITTER_CLIENT_SECRET=${{ secrets.TWITTER_CLIENT_SECRET_DEV }} >> .env
echo GITHUB_CLIENT_ID=${{ secrets.CLIENT_ID_GITHUB_DEV }} >> .env
echo GITHUB_CLIENT_SECRET=${{ secrets.CLIENT_SECRET_GITHUB_DEV }} >> .env
php artisan key:generate
php artisan migrate --seed
- name: Install front-end dependencies
run: |
npm install
npm run build
- name: Run Test
run: php artisan test --parallel

setup-build-publish-deploy:
<<<<<<< HEAD:.github/workflows/prod-build.yml
name: Build & deploy to production
if: github.ref == 'refs/heads/prod-helm-deploy'
needs: php-unit-test
runs-on: ubuntu-latest
=======
name: Build & deploy to development
runs-on: ubuntu-latest
needs: php-unit-test
environment:
name: Dev
url: ${{ env.DEV_URL }}
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd:.github/workflows/dev-build.yml
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -41,12 +131,41 @@ jobs:
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}

<<<<<<< HEAD
=======
<<<<<<< HEAD:.github/workflows/prod-build.yml
#Fetch latest release
- name: Fetch latest release
id: fetch-latest-release
uses: InsonusK/get-latest-release@v1.0.1
with:
myToken: ${{ github.token }}
#exclude_types: "draft|prerelease"
view_top: 10
- name: "Print release name"
run: |
echo "tag_name: ${{ steps.fetch-latest-release.outputs.tag_name }}"
# 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 }}

=======
# Login to Docker
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ env.DOCKER_HUB_PASSWORD }}

<<<<<<< HEAD
=======
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd:.github/workflows/dev-build.yml
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd
# Build and push the app Docker image
- name: Build and push App Docker image
uses: docker/build-push-action@v4
Expand All @@ -55,8 +174,18 @@ jobs:
file: ./resources/ops/docker/app/app.dockerfile
push: true
build-args: |
<<<<<<< HEAD
RELEASE_VERSION=dev-app-latest
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-app-latest
=======
<<<<<<< HEAD:.github/workflows/prod-build.yml
RELEASE_VERSION=app-${{ steps.fetch-latest-release.outputs.tag_name }}
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:app-latest, ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:app-${{ steps.fetch-latest-release.outputs.tag_name }}
=======
RELEASE_VERSION=dev-app-latest
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-app-latest
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd:.github/workflows/dev-build.yml
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ env.DOCKER_HUB_PASSWORD }}

Expand All @@ -68,16 +197,32 @@ jobs:
file: ./resources/ops/docker/nginx/nginx.dockerfile
push: true
build-args: |
<<<<<<< HEAD
RELEASE_VERSION=dev-nginx-latest
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-nginx-latest
=======
<<<<<<< HEAD:.github/workflows/prod-build.yml
RELEASE_VERSION=nginx-${{ steps.fetch-latest-release.outputs.tag_name }}
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:nginx-latest, ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:nginx-${{ steps.fetch-latest-release.outputs.tag_name }}
=======
RELEASE_VERSION=dev-nginx-latest
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-nginx-latest
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd:.github/workflows/dev-build.yml
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ env.DOCKER_HUB_PASSWORD }}

# Deploy the latest Docker image to the GKE cluster
- name: Deploy
run: |-
kubectl rollout restart deployment/$DEPLOYMENT_NAME
<<<<<<< HEAD
kubectl rollout restart deployment/$WORKER_DEPLOYMENT_NAME
kubectl rollout restart deployment/$SCHEDULER_DEPLOYMENT_NAME
kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s
=======
kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s
kubectl rollout restart deployment/$WORKER_DEPLOYMENT_NAME
kubectl rollout restart deployment/$SCHEDULER_DEPLOYMENT_NAME
>>>>>>> 4236d59f1a31b09b213ff2d700c92f4fb8062cfd
kubectl get services -o wide
4 changes: 4 additions & 0 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ env:


jobs:
# php-unit-test:
# uses: NFDI4Chem/nmrxiv/.github/workflows/test.yml@development

php-unit-test:
name: Run test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -132,6 +135,7 @@ jobs:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ env.DOCKER_HUB_PASSWORD }}

# Deploy the latest Docker image to the GKE cluster
- name: Deploy
run: |-
kubectl rollout restart deployment/$DEPLOYMENT_NAME
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name : Test

on:
workflow_call:

jobs:
php-unit-test:
name: Run test
runs-on: ubuntu-latest
container:
image: kirschbaumdevelopment/laravel-test-runner:8.2

services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: nmrxiv
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Install composer dependencies
run: |
composer install --ignore-platform-reqs
- name: Prepare Laravel Application
run: |
php -r "file_exists('.env') || copy('.env.ci.test', '.env');"
echo AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID_DEV }} >> .env
echo AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} >> .env
echo MEILISEARCH_KEY=${{ secrets.MEILISEARCH_KEY_DEV }} >> .env
echo MEILISEARCH_PUBLICKEY=${{ secrets.MEILISEARCH_PUBLICKEY_DEV }} >> .env
echo TWITTER_CLIENT_ID=${{ secrets.TWITTER_CLIENT_ID_DEV }} >> .env
echo TWITTER_CLIENT_SECRET=${{ secrets.TWITTER_CLIENT_SECRET_DEV }} >> .env
echo GITHUB_CLIENT_ID=${{ secrets.CLIENT_ID_GITHUB_DEV }} >> .env
echo GITHUB_CLIENT_SECRET=${{ secrets.CLIENT_SECRET_GITHUB_DEV }} >> .env
php artisan key:generate
php artisan migrate --seed
- name: Install front-end dependencies
run: |
npm install
npm run build
- name: Run Test
run: php artisan test --parallel
Loading

0 comments on commit 8aed0de

Please sign in to comment.