-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (67 loc) · 2.3 KB
/
build.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
name: Docker Image CI
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up node version
uses: actions/setup-node@v3
with:
node-version: '16.16'
- name: Show node and npm version
run: |
corepack enable
node -v
npm -v
shell: bash
- name: Git config
run: |
git config --global url."https://github.com/".insteadOf ssh://[email protected]/
git config --add --global url."https://github.com/".insteadOf [email protected]:
- name: Install dependencies
run: cd myapp && npm install
shell: bash
- name: build frontend
run: cd myapp && npm run build
shell: bash
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/jku-vds-lab/publictransport
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
restart-aws:
name: Restart AWS ECS Task
runs-on: ubuntu-latest
needs: [build]
steps:
- name: AWS Login
env:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
awsFamily: publictransport
run: |
isTaskRunning=$(aws --output text ecs list-tasks --cluster JKU_ASG_Cluster --family ${awsFamily})
echo "isTaskRunning? --${isTaskRunning}--"
if [ ! -z "$isTaskRunning" ]; then
taskId=$(echo "${isTaskRunning}" | cut -f2)
echo "taskId--${taskId}--"
aws --output text ecs stop-task --cluster JKU_ASG_Cluster --task ${taskId}
fi
aws --output text ecs run-task --cluster JKU_ASG_Cluster --task-definition ${awsFamily} --started-by GithubAction