Skip to content

Commit

Permalink
Merge pull request #18 from MinaFoundation/pm-1929-leader-bot-ci
Browse files Browse the repository at this point in the history
PM-1929 - Configure CI to build and publish the docker image
  • Loading branch information
johnmarcou authored Sep 9, 2024
2 parents 1a4e400 + ac3994d commit ac901d9
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 3 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build - publish

on:
push:
branches:
- main
workflow_dispatch:
inputs:
docker_tag_suffix:
description: "Enter a Docker Tag suffix (e.g dev)\nSuffixed images will not be auto-deployed"
required: false
type: string

env:
ECR_REPOSITORY_URL: 673156464838.dkr.ecr.us-west-2.amazonaws.com
ECR_REPOSITORY_NAME: pgt-leader-bot

jobs:
build-publish:
name: Build and Publish Docker Image
runs-on: minafoundation-default-runners
steps:
- name: 📥 Checkout
uses: actions/checkout@v4

- name: 🦀 Get application version from setup.py
id: application-version
run: |
version=$(grep "version" setup.py | head -1 | cut -d'"' -f2)
echo "current-version=$version" >> "$GITHUB_OUTPUT"
- name: 🏷️ Generate Tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
if [ "${{ github.event.inputs.docker_tag_suffix }}" != "" ]; then
echo "TAG=${{ steps.application-version.outputs.current-version }}-${{ github.event.inputs.docker_tag_suffix }}" >> $GITHUB_ENV
else
echo "TAG=${{ steps.application-version.outputs.current-version }}" >> $GITHUB_ENV
fi
elif [ "${{ github.event_name }}" == "push" ] && [ -n "${{ github.event.ref }}" ]; then
echo "TAG=${{ steps.application-version.outputs.current-version }}" >> $GITHUB_ENV
else
echo "Invalid event. Exiting..."
exit 1
fi
- name: 🔑 ECR Login
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: 🔍 Check if Tag already exists
id: checktag
uses: tyriis/docker-image-tag-exists@main
with:
registry: ${{ env.ECR_REPOSITORY_URL}}
repository: ${{ env.ECR_REPOSITORY_NAME }}
tag: ${{ env.TAG }}

- name: 🛠️ Build and Push Docker
uses: mr-smithers-excellent/docker-build-push@v6
if: steps.checktag.outputs.tag == 'not found'
with:
image: ${{ env.ECR_REPOSITORY_NAME }}
registry: ${{ env.ECR_REPOSITORY_URL }}
tags: ${{ env.TAG }}
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY . .
COPY github_tracker_bot github_tracker_bot
COPY leader_bot leader_bot
COPY utils utils
COPY config.py .
COPY log_config.py .
COPY __init__.py .

# Possible [ github_tracker_bot/bot.py (default), leader_bot/bot.py ]
CMD ["python", "github_tracker_bot/bot.py"]
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
from setuptools import find_packages, setup

setup(
name="pgt_leaderbot",
version="0.1",
version="0.3.1",
packages=find_packages(),
)

0 comments on commit ac901d9

Please sign in to comment.