slim python #70
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: [ "main", "rollback" ] | |
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://git@github.com/ | |
git config --add --global url."https://github.com/".insteadOf git@github.com: | |
- 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 |