Skip to content

Commit

Permalink
Added create and push tag and create release
Browse files Browse the repository at this point in the history
  • Loading branch information
MukuFlash03 committed Oct 8, 2024
1 parent d5fc419 commit ecedcc1
Showing 1 changed file with 46 additions and 16 deletions.
62 changes: 46 additions & 16 deletions .github/workflows/reusable_image_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
echo "tag_name=$(echo "$response" | jq -r '.tag_name')" >> "$GITHUB_OUTPUT"
echo "target_commitish=$(echo "$response" | jq -r '.target_commitish')" >> "$GITHUB_OUTPUT"
- name: Fetch latest server image tag
- name: Fetch current server image tag
id: get-server-tag
# if: ${{ inputs.repo == 'op-admin-dashboard' || inputs.repo == 'em-public-dashboard' }}
if: ${{ inputs.repo == 'op-admin-dashboard' || inputs.repo == 'em-public-dashboard' || inputs.repo == 'nrel-openpath-join-page' }}
Expand All @@ -53,24 +53,17 @@ jobs:
response=$(curl -L -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_FG_PAT_TAGS }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/MukuFlash03/e-mission-server/git/refs/tags")
# "https://api.github.com/repos/MukuFlash03/e-mission-server/releases/latest")
"https://api.github.com/repos/MukuFlash03/e-mission-server/releases")
# SERVER_IMAGE_TARGET=$(echo "$response" | jq -r '.target_commitish')
# SERVER_IMAGE_TAG=$(echo "$response" | jq -r '.tag_name')
tags=$(echo "$response_r" | jq -r '.[].tag_name')
current_server_release_tag=$(echo "$tags" | sort -V | tail -n 1)
previous_server_release_tag=$(echo "$tags" | sort -V | tail -n 2 | head -n 1)
# echo "SERVER_IMAGE_TAG=$(echo "$response" | jq -r '.tag_name')" >> "$GITHUB_OUTPUT"
# echo "SERVER_IMAGE_TARGET=$(echo "$response" | jq -r '.target_commitish')" >> "$GITHUB_OUTPUT"
tags=$(echo "$response" | jq -r '.[].ref' | cut -d'/' -f3)
latest_tag=$(echo "$tags" | sort -V | tail -n 1)
previous_tag=$(echo "$tags" | sort -V | tail -n 2 | head -n 1)
echo "SERVER_IMAGE_TAG=$latest_tag" >> "$GITHUB_OUTPUT"
echo "PREVIOUS_SERVER_TAG=$previous_tag" >> "$GITHUB_OUTPUT"
echo "SERVER_IMAGE_TAG=$current_server_release_tag" >> "$GITHUB_OUTPUT"
echo "PREVIOUS_SERVER_TAG=$previous_server_release_tag" >> "$GITHUB_OUTPUT"
echo "Latest server tag: $latest_tag"
echo "Previous server tag: $previous_tag"
echo "Latest server release tag: $current_server_release_tag"
echo "Previous server release tag: $previous_server_release_tag"

- name: Bump up release tag
# if: ${{ inputs.repo == 'op-admin-dashboard' || inputs.repo == 'em-public-dashboard' }}
Expand Down Expand Up @@ -144,11 +137,15 @@ jobs:
set -a; source .env; set +a
if [ "${{ inputs.repo }}" = "e-mission-server" ]; then
echo "SERVER_IMAGE_TAG=${SERVER_IMAGE_TAG}" >> "$GITHUB_OUTPUT"
echo "CURRENT_REPO_TAG=${SERVER_IMAGE_TAG}" >> "$GITHUB_OUTPUT"
elif [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then
echo "JOIN_IMAGE_TAG=${JOIN_IMAGE_TAG}" >> "$GITHUB_OUTPUT"
echo "CURRENT_REPO_TAG=${JOIN_IMAGE_TAG}" >> "$GITHUB_OUTPUT"
elif [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then
echo "ADMIN_DASH_IMAGE_TAG=${ADMIN_DASH_IMAGE_TAG}" >> "$GITHUB_OUTPUT"
echo "CURRENT_REPO_TAG=${ADMIN_DASH_IMAGE_TAG}" >> "$GITHUB_OUTPUT"
elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then
echo "CURRENT_REPO_TAG=${PUBLIC_DASH_NOTEBOOK_IMAGE_TAG}" >> "$GITHUB_OUTPUT"
echo "PUBLIC_DASH_NOTEBOOK_IMAGE_TAG=${PUBLIC_DASH_NOTEBOOK_IMAGE_TAG}" >> "$GITHUB_OUTPUT"
echo "PUBLIC_DASH_FRONTEND_IMAGE_TAG=${PUBLIC_DASH_FRONTEND_IMAGE_TAG}" >> "$GITHUB_OUTPUT"
fi
Expand Down Expand Up @@ -291,6 +288,39 @@ jobs:
fi
cat .env
- name: Create, Push new tag and Publish release
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "Github Actions bot to update .env with latest tags"
git tag -a ${{ steps.increment-release-tag.outputs.new_repo_version }} \
-m “$(git log --pretty=format:%s ${{ steps.set-tags.outputs.CURRENT_REPO_TAG }}…HEAD -—no-merges)“
git push origin ${{ steps.increment-release-tag.outputs.new_repo_version }}
echo "Logging latest created and pushed tag"
git describe --abbrev=0 --tags
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_FG_PAT_TAGS }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/MukuFlash03/${{ inputs.repo }}/releases \
-d '{"tag_name":${{ steps.increment-release-tag.outputs.new_repo_version }}, \
"target_commitish":${{ inputs.branch }}, \
"name":${{ steps.increment-release-tag.outputs.new_repo_version }}, \
"body":"Triggered on e-mission-server new release. Bumping up release version for ${{ inputs.repo}}", \
"generate_release_notes":true \
}'
echo "Logging latest created release"
latest_release=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_FG_PAT_TAGS }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/MukuFlash03/${{ inputs.repo }}/releases/latest)
- name: Add, Commit, Push changes to .env file
if: ${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
run: |
Expand Down

0 comments on commit ecedcc1

Please sign in to comment.