-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the deployment CI to add ONTOPORTAL_APIKEY as GH secret
- Loading branch information
1 parent
ff3f675
commit 2a50677
Showing
1 changed file
with
40 additions
and
27 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 |
---|---|---|
@@ -1,80 +1,93 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: [ "*" ] | ||
branches: | ||
- "main" | ||
tags: | ||
- "*" | ||
|
||
env: | ||
KUBECONFIG: .kube/config | ||
KUBECONFIG_FILE: ${{ secrets.KUBECONFIG }} | ||
|
||
jobs: | ||
build: | ||
name: "Build Image" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- id: generate-image-tag | ||
name: Generate Image Tag | ||
env: | ||
ref_name: "${{ github.ref_name }}" | ||
head_ref: "${{ github.head_ref }}" | ||
run: | | ||
head_ref="${head_ref/\//-}" | ||
ref_name="${head_ref:-${ref_name/main/latest}}" | ||
echo "::set-output name=imageTag::${ref_name#v}" | ||
head_ref="${GITHUB_HEAD_REF//\//-}" | ||
ref_name="${head_ref:-${GITHUB_REF_NAME/main/latest}}" | ||
echo "imageTag=${ref_name#v}" >> $GITHUB_ENV | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'temurin' | ||
distribution: 'temurin' | ||
java-version: '11' | ||
|
||
- name: Build with Maven | ||
run: mvn clean install | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./ | ||
file: ./Dockerfile | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository }}:${{ steps.generate-image-tag.outputs.imageTag }} | ||
ghcr.io/${{ github.repository }}:${{ env.imageTag }} | ||
ghcr.io/${{ github.repository }}:${{ github.event.pull_request.head.sha || github.sha }} | ||
deploy_main: | ||
needs: build | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
steps: | ||
needs: build | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: generate-image-tag | ||
name: Generate Image Tag | ||
env: | ||
ref_name: "${{ github.ref_name }}" | ||
head_ref: "${{ github.head_ref }}" | ||
run: | | ||
head_ref="${head_ref/\//-}" | ||
ref_name="${head_ref:-${ref_name/main/latest}}" | ||
echo "::set-output name=imageTag::${ref_name#v}" | ||
head_ref="${GITHUB_HEAD_REF//\//-}" | ||
ref_name="${head_ref:-${GITHUB_REF_NAME/main/latest}}" | ||
echo "imageTag=${ref_name#v}" >> $GITHUB_ENV | ||
- uses: actions/checkout@v2 | ||
- run: | | ||
|
||
- name: Set up Kubernetes config | ||
run: | | ||
mkdir -p .kube | ||
echo "${{ env.KUBECONFIG_FILE }}" > $KUBECONFIG | ||
- uses: stefanprodan/kube-tools@v1 | ||
echo "${{ secrets.KUBECONFIG }}" > $KUBECONFIG | ||
- name: Create Kubernetes secret for ONTOPORTAL_APIKEY | ||
run: | | ||
kubectl create secret generic ontoportal-secret \ | ||
--from-literal=ONTOPORTAL_APIKEY=${{ secrets.ONTOPORTAL_APIKEY }} \ | ||
--dry-run=client -o yaml | kubectl apply -f - | ||
- name: Deploy to Kubernetes | ||
uses: stefanprodan/kube-tools@v1 | ||
with: | ||
helmv3: 3.12.0 | ||
command: | | ||
kubectl get nodes | ||
helmv3 repo add api-gateway-deployment https://ts4nfdi.github.io/api-gateway-deployment/ | ||
helmv3 repo update | ||
helmv3 upgrade ts4nfdi \ | ||
--install \ | ||
api-gateway-deployment/api-gateway | ||
--install \ | ||
api-gateway-deployment/api-gateway |