Skip to content

Commit

Permalink
/deploy sit
Browse files Browse the repository at this point in the history
  • Loading branch information
sliu008 committed Jan 7, 2025
1 parent 150d5c0 commit 73c3d61
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:
fi
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
echo "the_version=${new_version}" >> $GITHUB_ENV
poetry version ${new_version}
- name: Install Dependencies and Run Tests
Expand Down Expand Up @@ -102,8 +101,8 @@ jobs:
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git commit -am "/version ${{ env.the_version }}"
git tag -a "${{ env.the_version }}" -m "Version ${{ env.the_version }}"
git commit -am "/version ${{ env.new_version }}"
git tag -a "${{ env.new_version }}" -m "Version ${{ env.new_version }}"
git push --follow-tags
- name: Create and Upload Release
Expand All @@ -113,7 +112,7 @@ jobs:
startsWith(github.ref, 'refs/heads/release')
uses: ncipollo/[email protected]
with:
tag: ${{ env.the_version }}
tag: ${{ env.new_version }}
artifacts: "*.zip"
token: ${{ secrets.GITHUB_TOKEN }}
makeLatest: ${{ github.ref == 'refs/heads/main' }}
Expand Down Expand Up @@ -172,13 +171,56 @@ jobs:
pip install tenacity logging
python3 ${GITHUB_WORKSPACE}/.github/workflows/wait-for-pypi.py ${{needs.build.outputs.pyproject_name}}[harmony]==${{ needs.build.outputs.version }}
- name: Set Environment Variables
run: |
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" =~ ^refs/heads/release/ ]]; then
echo "TARGET_ENV_UPPERCASE=UAT" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "TARGET_ENV_UPPERCASE=OPS" >> $GITHUB_ENV
fi
- name: Deploy Env Override
if: contains(github.event.head_commit.message, '/deploy')
run: |
message="${{ github.event.head_commit.message }}"
trimmed_message=${message:1} # Remove leading slash
override_env=$(echo "$trimmed_message" | grep -oE '[^[:space:]]+$')
override_env_upper=$(echo "$trimmed_message" | awk '{print toupper($NF)}')
echo "TARGET_ENV_UPPERCASE=${override_env_upper}" >> $GITHUB_ENV
- name: Lower Case Target Env
run: |
original_env_value="${TARGET_ENV_UPPERCASE}"
lowercase_value=$(echo "${original_env_value}" | tr '[:upper:]' '[:lower:]')
echo "TARGET_ENV_LOWERCASE=${lowercase_value}" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
if: |
steps.pypi-test-publish.conclusion == 'success' ||
steps.pypi-publish.conclusion == 'success' ||
github.event.head_commit.message == '/deploy sit' ||
github.event.head_commit.message == '/deploy uat' ||
github.event.head_commit.message == '/deploy sandbox'
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ github.ref == 'refs/heads/main' }}
tags: |
type=semver,pattern={{raw}},value=${{ needs.build.outputs.version }}
type=raw,value=${{ env.TARGET_ENV_LOWERCASE }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/lambdaDockerfileArm
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/arm64
build-args: |
DIST_PATH: ${{ contains(github.event.head_commit.message, '/deploy') && 'dist/' || '' }}
Expand Down

0 comments on commit 73c3d61

Please sign in to comment.