Skip to content

Image Diff (#47)

Image Diff (#47) #5

Workflow file for this run

name: Deploy Docker Image
env:
PROJECT_NAME: loops
on:
push:
branches: ['main']
tags: '*'
jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- 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: 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/${{ env.PROJECT_NAME }}
- name: Print metadata
run: |
echo ${{ steps.meta.outputs.tags }}
- 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: [deploy]
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 }}
steps:
- name: Check if Task is Running and Stop it
run: |
isTaskRunning=$(aws --output text ecs list-tasks --cluster JKU_ASG_Cluster --family ${PROJECT_NAME})
if [ ! -z "$isTaskRunning" ]; then
echo "TASK IS RUNNING "
taskId=$(echo "${isTaskRunning}" | cut -f2)
echo "STOPPING TASK with taskId: ${taskId}"
aws --output text ecs stop-task --cluster JKU_ASG_Cluster --task ${taskId}
else
echo "TASK STOPPED"
fi
- name: Start Task
run: |
aws --output text ecs run-task --cluster JKU_ASG_Cluster --task-definition ${PROJECT_NAME} --started-by GithubAction