Skip to content

Commit

Permalink
Merge pull request #6 from PSNAppz/1.0
Browse files Browse the repository at this point in the history
Updated workflows
  • Loading branch information
venky-ganapathy authored Dec 9, 2024
2 parents 14ed5b1 + 9ecce0a commit d738f60
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 7 deletions.
File renamed without changes.
64 changes: 64 additions & 0 deletions .github/workflows/beat-producers-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: SR BG Tasks Beat Producers Tag Workflow

on:
push:
tags:
- "*"
branches-ignore:
- '*'
workflow_dispatch:

jobs:
publish-to-pypi:
name: Publish to PyPI For Beat Producers Tag
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/checkout@v3
- name: Install build dependencies
run: pip install build
- name: Build distribution
run: python -m build ./openg2p-sr-celery-beat-producers
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: ./openg2p-sr-celery-beat-producers/dist/

docker-build-for-tag:
name: Docker Build and Push For Beat Producers Tag
needs: publish-to-pypi
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.docker_hub_organisation || 'openg2p' }}
SERVICE_NAME: openg2p-sr-celery-beat-producers
steps:
- uses: actions/checkout@v3
- name: Docker build
run: |
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
IMAGE_ID=$NAMESPACE/$SERVICE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$TAG_NAME
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
echo VERSION=$VERSION >> $GITHUB_ENV
docker build ./openg2p-sr-celery-beat-producers -f ./openg2p-sr-celery-beat-producers/Dockerfile-pypi \
--tag $IMAGE_ID:$VERSION
if [[ '${{ secrets.docker_hub_token }}' != '' && '${{ secrets.docker_hub_actor }}' != '' ]]; then
export DOCKER_PUSH="true"
echo DOCKER_PUSH=$DOCKER_PUSH >> $GITHUB_ENV
fi
- name: Docker push
if: env.DOCKER_PUSH == 'true'
run: |
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}
65 changes: 65 additions & 0 deletions .github/workflows/workers-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: SR BG Tasks Celery Worker Tag Workflow

on:
push:
tags:
- "*"
branches-ignore:
- '*'
workflow_dispatch:

jobs:
publish-to-pypi:
name: Publish to PyPI For Workers Tag
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/checkout@v3
- name: Install build dependencies
run: pip install build
- name: Build distribution
run: python -m build ./openg2p-sr-celery-workers
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: ./openg2p-sr-celery-workers/dist/


docker-build-for-tag:
name: Docker Build and Push For Workers Tag
needs: publish-to-pypi
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.docker_hub_organisation || 'openg2p' }}
SERVICE_NAME: openg2p-sr-celery-workers
steps:
- uses: actions/checkout@v3
- name: Docker build
run: |
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
IMAGE_ID=$NAMESPACE/$SERVICE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$TAG_NAME
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
echo VERSION=$VERSION >> $GITHUB_ENV
docker build ./openg2p-sr-celery-workers -f ./openg2p-sr-celery-workers/Dockerfile-pypi \
--tag $IMAGE_ID:$VERSION
if [[ '${{ secrets.docker_hub_token }}' != '' && '${{ secrets.docker_hub_actor }}' != '' ]]; then
export DOCKER_PUSH="true"
echo DOCKER_PUSH=$DOCKER_PUSH >> $GITHUB_ENV
fi
- name: Docker push
if: env.DOCKER_PUSH == 'true'
run: |
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}
6 changes: 3 additions & 3 deletions openg2p-sr-celery-beat-producers/Dockerfile-pypi
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ ADD --chown=${container_user}:${container_user_group} main.py /app
RUN python3 -m venv venv \
&& . ./venv/bin/activate
RUN python3 -m pip install \
openg2p-fastapi-common==1.1.0 \
openg2p-fastapi-auth==1.1.0 \
openg2p-fastapi-common==1.1.1 \
openg2p-fastapi-auth==1.1.1 \
openg2p-sr-models==1.0.0 \
openg2p-sr-celery-beat-producers
openg2p-sr-celery-beat-producers==1.0.0

USER ${container_user}

Expand Down
8 changes: 4 additions & 4 deletions openg2p-sr-celery-workers/Dockerfile-pypi
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ ADD --chown=${container_user}:${container_user_group} main.py /app
RUN python3 -m venv venv \
&& . ./venv/bin/activate
RUN python3 -m pip install \
openg2p-fastapi-common==develop \
openg2p-fastapi-auth==develop \
openg2p-sr-models==develop \
openg2p-sr-celery-workers
openg2p-fastapi-common==1.1.1 \
openg2p-fastapi-auth==1.1.1 \
openg2p-sr-models==1.0.0 \
openg2p-sr-celery-workers==1.0.0

USER ${container_user}

Expand Down

0 comments on commit d738f60

Please sign in to comment.