Skip to content

Update Image Tag

Update Image Tag #4

name: Update Image Tag
on:
workflow_dispatch:
push:
branches:
- main
paths:
- app.version
jobs:
update-image-tag:
runs-on: ubuntu-latest
steps:
- name: Get app token
uses: actions/[email protected]
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Get new version
id: get_version
run: |
NEW_VERSION=$(grep '^appVersion:' app.version | awk '{print $2}')
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Checkout FBF Config Repo
uses: actions/checkout@v4
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
with:
repository: ${{ github.repository_owner }}/${{ secrets.deployment_repo }}
- name: Create new branch and update image tag
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
NEW_VERSION=${{ steps.get_version.outputs.new_version }}
BRANCH_NAME="release/${NEW_VERSION}"
# Create a new branch
git checkout -b $BRANCH_NAME
# Update the image.tag in values.yaml
sed "s/^appVersion: .*/appVersion: \"$new_version\"/" event-buddy/Chart.yaml
git add event-buddy/Chart.yaml
git commit -m "Update image tag to $NEW_VERSION"
git push origin $BRANCH_NAME
# Create a pull request using GitHub GraphQL API
PR_QUERY=$(cat <<EOF
mutation {
createPullRequest(input: {
repositoryId: "$(gh api graphql -f query='query { repository(owner: "your-username", name: "fbf-event-buddy-config") { id } }' -q .data.repository.id)"
title: "Update image tag to $NEW_VERSION"
headRefName: "$BRANCH_NAME"
baseRefName: "main"
body: "This PR updates the image tag to $NEW_VERSION."
maintainerCanModify: true
}) {
pullRequest {
url
}
}
}
EOF
)
gh api graphql -f query="$PR_QUERY"