Skip to content

Merge pull request #299 from LACMTA/update-realtime-stops-format #188

Merge pull request #299 from LACMTA/update-realtime-stops-format

Merge pull request #299 from LACMTA/update-realtime-stops-format #188

Workflow file for this run

# 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 '{"fastapi":{"image":"lacmta/metro-api-v2:fastapi","ports":{"80":"HTTP"},"environment":{"FTP_PASS":"${{secrets.FTP_PASS }}","FTP_SERVER":"${{secrets.FTP_SERVER }}","FTP_USERNAME":"${{secrets.FTP_USERNAME }}","SWIFTLY_AUTH_KEY_BUS":"${{secrets.SWIFTLY_AUTH_KEY_BUS}}","SWIFTLY_AUTH_KEY_RAIL":"${{secrets.SWIFTLY_AUTH_KEY_RAIL}}","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","MAIL_USERNAME":"${{secrets.MAIL_USERNAME}}","MAIL_PASSWORD":"${{secrets.MAIL_PASSWORD}}","MAIL_SERVER":"${{secrets.MAIL_SERVER}}"}},"data-loading-service":{"image":"lacmta/metro-api-v2:data-loading-service","environment":{"FTP_PASS":"${{secrets.FTP_PASS }}","FTP_SERVER":"${{secrets.FTP_SERVER }}","FTP_USERNAME":"${{secrets.FTP_USERNAME }}","SWIFTLY_AUTH_KEY_BUS":"${{secrets.SWIFTLY_AUTH_KEY_BUS}}","SWIFTLY_AUTH_KEY_RAIL":"${{secrets.SWIFTLY_AUTH_KEY_RAIL}}","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","MAIL_USERNAME":"${{secrets.MAIL_USERNAME}}","MAIL_PASSWORD":"${{secrets.MAIL_PASSWORD}}","MAIL_SERVER":"${{secrets.MAIL_SERVER}}"}}}' --public-endpoint '{"containerName": "fastapi","containerPort": 80,"healthCheck":{ "healthyThreshold": 2,"unhealthyThreshold": 2,"timeoutSeconds": 2,"intervalSeconds": 5,"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