-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (129 loc) · 4.89 KB
/
learningpath-api_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# AUTOGENERATED BY: project/GithubWorkflowPlugin.scala (sbt `ghGenerate`)
# DO NOT EDIT MANUALLY.
name: 'Release: learningpath-api'
on:
workflow_dispatch:
inputs: { }
push:
branches:
- master
paths:
- learningpath-api/**
- project/learningpathapi*.scala
- network/**
- project/network*.scala
- mapping/**
- project/mapping*.scala
- language/**
- project/language*.scala
- common/**
- project/common*.scala
- search/**
- project/search*.scala
- database/**
- project/database*.scala
- scalatestsuite/**
- project/scalatestsuite*.scala
- tapirtesting/**
- project/tapirtesting*.scala
- project/Dependencies.scala
- project/Module.scala
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_CLIENT_ID }}
AWS_DEFAULT_REGION: eu-west-1
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_CLIENT_SECRET }}
NDLA_AWS_ECR_REPO: ${{ secrets.NDLA_AWS_ECR_REPO }}
CI_RELEASE_ROLE: ${{ secrets.CI_RELEASE_ROLE }}
CI_GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
NDLA_RELEASES: ${{ secrets.NDLA_RELEASES }}
NDLA_ENVIRONMENT: local
NDLA_HOME: ${{ github.workspace }}/ndla
NDLA_DEPLOY: ${{ github.workspace }}/ndla/deploy
COMPONENT: learningpath-api
GPG_KEY: ${{ secrets.DEPLOY_BLACKBOX_GPG_KEY_B64 }}
jobs:
release:
name: Release and push to registry
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: ndla/${{ github.event.repository.name }}
- uses: actions/checkout@v4
with:
repository: NDLANO/deploy
token: ${{ secrets.CI_GITHUB_TOKEN }}
path: ndla/deploy
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.6.1"
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: '20'
- name: Setup ~/bin directory
run: |
mkdir -p /home/runner/bin
echo "/home/runner/bin" >> $GITHUB_PATH
- name: Login to ECR repo
run: RES=$(aws sts assume-role --role-arn $CI_RELEASE_ROLE --role-session-name
github-actions-ecr-login) AWS_ACCESS_KEY_ID=$(echo $RES | jq -r .Credentials.AccessKeyId)
AWS_SECRET_ACCESS_KEY=$(echo $RES | jq -r .Credentials.SecretAccessKey) AWS_SESSION_TOKEN=$(echo
$RES | jq -r .Credentials.SessionToken) aws ecr get-login-password --region
eu-central-1 | docker login --username AWS --password-stdin $NDLA_AWS_ECR_REPO
- name: Login to dockerhub
run: echo $DOCKER_HUB_PASSWORD | docker login --username $DOCKER_HUB_USERNAME
--password-stdin
- name: Cache pip
uses: actions/cache@v3
with:
path: ndla/deploy/.venv
key: ${{ runner.os }}-pip-${{ hashFiles('ndla/deploy/poetry.lock')
}}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install python dependencies
run: |
# Setup the virtualenv in the repo to make caching of dependencies easier
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
# Install the deps!
poetry --directory $NDLA_DEPLOY install
- name: Download blackbox
uses: actions/checkout@v3
with:
repository: StackExchange/blackbox
path: blackbox
- name: Install Blackbox and key
run: |
# Move binaries to path
sudo mv blackbox/bin/* /home/runner/bin/
echo -n "$GPG_KEY" | base64 --decode | gpg --import
- name: Install kubectl
run: |
curl -L https://storage.googleapis.com/kubernetes-release/release/v1.21.11/bin/linux/amd64/kubectl > kubectl
sudo mv kubectl /home/runner/bin/kubectl
sudo chmod +x /home/runner/bin/kubectl
mkdir -p ~/.kube
- name: Install aws-iam-authenticator
run: |
sudo curl -L https://amazon-eks.s3-us-west-2.amazonaws.com/1.12.7/2019-03-27/bin/linux/amd64/aws-iam-authenticator > aws-iam-authenticator
sudo mv aws-iam-authenticator /home/runner/bin/aws-iam-authenticator
sudo chmod +x /home/runner/bin/aws-iam-authenticator
- name: Install helm /w push-plugin
run: |
curl -L https://get.helm.sh/helm-v3.11.3-linux-amd64.tar.gz > /tmp/helm.tar.gz
tar xvzf /tmp/helm.tar.gz -C /tmp/
sudo mv /tmp/linux-amd64/helm /home/runner/bin/
sudo chmod +x /home/runner/bin/helm
- name: Build kubernetes config
run: poetry -C $NDLA_DEPLOY run ndla env kubeconfig test
- name: Do release
shell: bash
run: poetry -C $NDLA_DEPLOY run ndla release $COMPONENT --update-chart