Skip to content

Commit

Permalink
Add workflow to release to main (#188)
Browse files Browse the repository at this point in the history
Workflow that retags images, changes tags in the code, and opens a PR to
main

---------

Co-authored-by: Renato L. de F. Cunha <renato.cunha@microsoft.com>
  • Loading branch information
robertomest and renatolfc authored Aug 1, 2024
1 parent 3060408 commit 5a4012d
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/release-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release to main
on:
workflow_dispatch:

permissions:
id-token: write
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest
environment: build
steps:
- uses: actions/checkout@v4
with:
ref: dev
- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Retag images
run: |
az acr login -n ${{ secrets.ACR_NAME }}
for image in api-orchestrator worker cache; do
export IMAGE_TAG=${{ secrets.ACR_NAME }}.azurecr.io/unlisted/farmai/terravibes/$image
export DEV_TAG=$IMAGE_TAG:dev
export MAIN_TAG=$IMAGE_TAG:${{ github.run_id }}
echo Retagging from $DEV_TAG to $MAIN_TAG
docker pull $DEV_TAG
docker tag $DEV_TAG $MAIN_TAG
docker push $MAIN_TAG
done
- name: Adjust default tag
run: |
ROOT=$(git rev-parse --show-toplevel)
CONSTANTS_MODULE="$ROOT"/src/vibe_core/vibe_core/cli/constants.py
sed -i "s|DEFAULT_IMAGE_TAG.*|DEFAULT_IMAGE_TAG = ${{ github.run_id }}|g" "$CONSTANTS_MODULE"
- name: Check modified file
run: cat src/vibe_core/vibe_core/cli/constants.py
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "farmvibesaicd@microsoft.com"
git config --global user.name "FarmVibes.AI Release Pipeline"
ROOT=$(git rev-parse --show-toplevel)
CONSTANTS_MODULE="$ROOT"/src/vibe_core/vibe_core/cli/constants.py
RELEASE_BRANCH=release-main-${{ github.run_id }}
git checkout -b $RELEASE_BRANCH
git add $CONSTANTS_MODULE
git commit -m "Update default tag to latest image"
git push --set-upstream origin $RELEASE_BRANCH

0 comments on commit 5a4012d

Please sign in to comment.