-
Notifications
You must be signed in to change notification settings - Fork 3
114 lines (106 loc) · 6.31 KB
/
dev-aws.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
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# Source Partly from: https://aws.amazon.com/getting-started/guides/deploy-webapp-lightsail/module-four/
name: Deploy Docker Image to Dev AWS Lightsail Container Service
on:
push:
branches:
- dev
workflow_dispatch:
jobs:
deploy-to-aws:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: 🔎 Check if files besides docs have changed
id: changed-files
uses: tj-actions/changed-files@v35
with:
files_ignore: documentation
- name: Upgrade AWS CLI version and setup lightsailctl
if: steps.changed-files.outputs.any_changed == 'true'
run: |
aws --version
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
which aws
aws --version
sudo curl "https://s3.us-west-2.amazonaws.com/lightsailctl/latest/linux-amd64/lightsailctl" -o "/usr/local/bin/lightsailctl"
sudo chmod +x /usr/local/bin/lightsailctl
- name: Configure AWS Credentials
if: steps.changed-files.outputs.any_changed == 'true'
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: ${{ secrets.AWS_REGION }}
- name: Set up Docker Buildx
if: steps.changed-files.outputs.any_changed == 'true'
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: steps.changed-files.outputs.any_changed == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push 1-data-loading-service
if: steps.changed-files.outputs.any_changed == 'true'
id: docker_build_data_loading_service
uses: docker/build-push-action@v2
with:
push: true
tags: lacmta/metro-api-v2:data-loading-service
context: ./data-loading-service/
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
- name: Build and push 2-fastapi
if: steps.changed-files.outputs.any_changed == 'true'
id: docker_build_fastapi
uses: docker/build-push-action@v2
with:
push: true
tags: lacmta/metro-api-v2:fastapi
context: ./fastapi/
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
- name: Push Updated Docker Image on Lightsail Dev
if: steps.changed-files.outputs.any_changed == 'true'
run: >
aws lightsail create-container-service-deployment --service-name dev-metro-api-v2 --containers '{"memcached": {"image": "memcached:latest", "environment": {}, "ports": {"11211": "TCP"}}, "data-loading-service": {"image":"lacmta/metro-api-v2:data-loading-service", "environment": {"FTP_SERVER": "${{secrets.FTP_SERVER}}", "FTP_USERNAME": "${{secrets.FTP_USERNAME}}", "FTP_PASS": "${{secrets.FTP_PASS}}", "SWIFTLY_AUTH_KEY_BUS": "${{secrets.SWIFTLY_AUTH_KEY_BUS}}", "SWIFTLY_AUTH_KEY_RAIL": "${{secrets.SWIFTLY_AUTH_KEY_RAIL}}", "AWS_ACCESS_KEY_ID": "${{secrets.AWS_ACCESS_KEY_ID}}", "ACCESS_SECRET_KEY": "${{secrets.ACCESS_SECRET_KEY}}", "SWIFTLY_AUTH_KEY": "${{secrets.SWIFTLY_AUTH_KEY}}", "API_DB_URI": "${{secrets.API_DB_URI}}", "HASH_KEY": "${{secrets.HASH_KEY}}", "HASHING_ALGORITHM": "${{secrets.HASHING_ALGORITHM}}", "LOGZIO_TOKEN": "${{secrets.LOGZIO_TOKEN}}", "LOGZIO_URL": "${{secrets.LOGZIO_URL}}", "RUNNING_ENV": "dev"}}, "fastapi": {"image":"lacmta/metro-api-v2:fastapi", "environment": {"FTP_SERVER": "${{secrets.FTP_SERVER}}", "FTP_USERNAME": "${{secrets.FTP_USERNAME}}", "FTP_PASS": "${{secrets.FTP_PASS}}", "SWIFTLY_AUTH_KEY_BUS": "${{secrets.SWIFTLY_AUTH_KEY_BUS}}", "SWIFTLY_AUTH_KEY_RAIL": "${{secrets.SWIFTLY_AUTH_KEY_RAIL}}", "AWS_ACCESS_KEY_ID": "${{secrets.AWS_ACCESS_KEY_ID}}", "ACCESS_SECRET_KEY": "${{secrets.ACCESS_SECRET_KEY}}", "SWIFTLY_AUTH_KEY": "${{secrets.SWIFTLY_AUTH_KEY}}", "API_DB_URI": "${{secrets.API_DB_URI}}", "HASH_KEY": "${{secrets.HASH_KEY}}", "HASHING_ALGORITHM": "${{secrets.HASHING_ALGORITHM}}", "LOGZIO_TOKEN": "${{secrets.LOGZIO_TOKEN}}", "LOGZIO_URL": "https://listener.logz.io:8071", "RUNNING_ENV": "dev", "MEMCACHED_HOST": "dev-metro-api-v2.service.local","MEMCACHED_PORT":"11211"}, "ports": {"80": "HTTP"}}}' --public-endpoint '{"containerName": "fastapi","containerPort": 80,"healthCheck":{ "healthyThreshold": 2,"unhealthyThreshold": 2,"timeoutSeconds": 15,"intervalSeconds": 20,"path": "/","successCodes": "200-499"}}'
deploy-documentation:
runs-on: ubuntu-latest
name: Deploy Documentation to GitHub Pages
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache-dependency-path: "./documentation/package.json"
- name: 🔎 Check for change in docs folder
id: changed-documentation
uses: tj-actions/changed-files@v35
with:
files: documentation
- name: Install dependencies
if: steps.changed-documentation.outputs.any_changed == 'true'
working-directory: ./documentation
run: yarn install
- name: Build website
if: steps.changed-documentation.outputs.any_changed == 'true'
working-directory: ./documentation
run: yarn build
- name: Deploy Documentation to GitHub Pages
if: steps.changed-documentation.outputs.any_changed == 'true'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.METRO_GITHUB_TOKEN }}
publish_dir: ./documentation/build
publish_branch: gh-pages
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com