Skip to content

Issue #673:

Issue #673: #36

Workflow file for this run

name: CI/CD
on: push
env:
PROJECT_NAME: a22-traffic-connector
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/a22-traffic-connector
DOCKER_TAG: ${{ github.sha }}
JAVA_VERSION: 8
jobs:
# TODO: disable again
# Disable test deployment, because heavy on database and docker resources
# Enable again if test environment is needed
# Deploy Test
deploy-test:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main'
concurrency: deploy-test
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
- name: Create .env file
uses: noi-techpark/github-actions/env-file@v2
env:
# General deployment options
X_COMPOSE_PROJECT_NAME: ${{ env.PROJECT_NAME }}
X_DOCKER_IMAGE: ${{ env.DOCKER_IMAGE }}
X_DOCKER_TAG: ${{ env.DOCKER_TAG }}
X_JAVA_OPTIONS: -Xms128m -Xmx2048m
X_JDBC_URL: ${{ secrets.TEST_JDBC_URL }}
X_OPERATION_MODE: "follow"
# X_OPERATION_MODE: "month 2024 11"
- name: Build project
uses: noi-techpark/github-actions/maven-build@v2
with:
java-version: ${{ env.JAVA_VERSION }}
build-command: 'mvn -B clean package'
- name: Build and push images
uses: noi-techpark/github-actions/docker-build-and-push@v2
with:
working-directory: infrastructure
docker-username: ${{ github.actor }}
docker-password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy application
uses: noi-techpark/github-actions/docker-deploy@v2
with:
working-directory: infrastructure/ansible
hosts: 'test'
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
docker-username: 'noi-techpark-bot'
docker-password: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
project-name: ${{ env.PROJECT_NAME }}
# Deploy Prod
deploy-prod:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/prod'
concurrency: deploy-prod
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
- name: Create .env file
uses: noi-techpark/github-actions/env-file@v2
env:
# General deployment options
X_COMPOSE_PROJECT_NAME: ${{ env.PROJECT_NAME }}
X_DOCKER_IMAGE: ${{ env.DOCKER_IMAGE }}
X_DOCKER_TAG: ${{ env.DOCKER_TAG }}
X_JAVA_OPTIONS: -Xms128m -Xmx2048m
X_JDBC_URL: ${{ secrets.PROD_JDBC_URL }}
X_OPERATION_MODE: "follow"
- name: Build project
uses: noi-techpark/github-actions/maven-build@v2
with:
java-version: ${{ env.JAVA_VERSION }}
build-command: 'mvn -B clean package'
- name: Build and push images
uses: noi-techpark/github-actions/docker-build-and-push@v2
with:
working-directory: infrastructure
docker-username: ${{ github.actor }}
docker-password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy application
uses: noi-techpark/github-actions/docker-deploy@v2
with:
working-directory: infrastructure/ansible
hosts: 'prod'
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
docker-username: 'noi-techpark-bot'
docker-password: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
project-name: ${{ env.PROJECT_NAME }}