Skip to content

SDLC - Stable create #6

SDLC - Stable create

SDLC - Stable create #6

Workflow file for this run

name: SDLC - Stable create
on:
create:
branches:
- 'stable/*'
jobs:
stable-create:
name: "Prepare application version"
runs-on: ubuntu-latest
if: github.event_name == 'create' && startsWith(github.ref, 'refs/heads/stable/')
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- id: version
name: Extract stable version from branch name
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/stable/}
VERSION=$(echo $BRANCH_NAME | cut -d '.' -f1,2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Remove rc suffix in pyproject.toml
run: |
git checkout $GITHUB_REF_NAME
sed -i 's/rc1//' pyproject.toml
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git commit -am "Remove rc suffix for stable release ${{ env.VERSION }}"
git push origin $GITHUB_REF_NAME
build-push-stable:
name: "Build & push image"
runs-on: ubuntu-latest
needs: [stable-create]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Retag and push stable image
run: |
docker pull ${{ vars.DOCKERHUB_ORGANIZATION }}/${{ vars.DOCKERHUB_REPOSITORY }}:${{ needs.stable-create.outputs.version }}rc1
docker tag ${{ vars.DOCKERHUB_ORGANIZATION }}/${{ vars.DOCKERHUB_REPOSITORY }}:${{ needs.stable-create.outputs.version }}rc1 ${{ vars.DOCKERHUB_ORGANIZATION }}/${{ vars.DOCKERHUB_REPOSITORY }}:${{ env.VERSION }}
docker push ${{ vars.DOCKERHUB_ORGANIZATION }}/${{ vars.DOCKERHUB_REPOSITORY }}:${{ needs.stable-create.outputs.version }}