Skip to content

Merge pull request #332 from Opetushallitus/snyk-upgrade-6ff71b12f26d… #127

Merge pull request #332 from Opetushallitus/snyk-upgrade-6ff71b12f26d…

Merge pull request #332 from Opetushallitus/snyk-upgrade-6ff71b12f26d… #127

name: Test and deploy master
on:
push:
branches:
- master
jobs:
test_and_deploy_dev:
name: Deploy to dev
environment:
name: dev
env:
ENV_NAME: dev
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Java 8
uses: actions/setup-java@v3
with:
java-version: '8'
architecture: 'x64'
distribution: 'zulu'
- name: Cache Maven packages
uses: actions/cache@v3
if: steps.check-image.image-exists != '0'
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Setup Node 16
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Cache Node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Assume role for target environment
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
role-to-assume: ${{ secrets.DEPLOYMENT_ROLE }}
role-duration-seconds: 3600
role-session-name: LokiDeployment-${{ github.event.inputs.commithash }}
- name: Deploy backend
run: |
cd parser
make deploy env=$ENV_NAME
- name: Deploy frontend
run: |
cd frontend
./deploy.sh $ENV_NAME
test_and_deploy_qa:
name: Deploy to qa
environment:
name: qa
needs: [test_and_deploy_dev]
env:
ENV_NAME: qa
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Java 8
uses: actions/setup-java@v3
with:
java-version: '8'
architecture: 'x64'
distribution: 'zulu'
- name: Cache Maven packages
uses: actions/cache@v3
if: steps.check-image.image-exists != '0'
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Setup Node 16
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Cache Node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Assume role for target environment
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
role-to-assume: ${{ secrets.DEPLOYMENT_ROLE }}
role-duration-seconds: 3600
role-session-name: LokiDeployment-${{ github.event.inputs.commithash }}
- name: Deploy backend
run: |
cd parser
make deploy env=$ENV_NAME
- name: Deploy frontend
run: |
cd frontend
./deploy.sh $ENV_NAME
test_and_deploy_prod:
name: Deploy to prod
environment:
name: prod
needs: [test_and_deploy_qa]
env:
ENV_NAME: prod
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Java 8
uses: actions/setup-java@v3
with:
java-version: '8'
architecture: 'x64'
distribution: 'zulu'
- name: Cache Maven packages
uses: actions/cache@v3
if: steps.check-image.image-exists != '0'
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Setup Node 16
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Cache Node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Assume role for target environment
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
role-to-assume: ${{ secrets.DEPLOYMENT_ROLE }}
role-duration-seconds: 3600
role-session-name: LokiDeployment-${{ github.event.inputs.commithash }}
- name: Deploy backend
run: |
cd parser
make deploy env=$ENV_NAME
- name: Deploy frontend
run: |
cd frontend
./deploy.sh $ENV_NAME