Skip to content
6 changes: 6 additions & 0 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ on:
required: false
description: EKS namespace
type: string
pushToEnvTag:
required: false
description: Push commits to env-named tags instead of the main branch
type: boolean
default: false
ref:
required: false
description: The github ref to deploy
Expand Down Expand Up @@ -96,6 +101,7 @@ jobs:
"namespace": "${{ inputs.namespace }}",
"versionKey": "${{ inputs.versionKey }}"
},
"pushToEnvTag": "${{ inputs.pushToEnvTag }}",
"statusUrl": ${{ toJSON(steps.k8s.outputs.status-url) }},
"url": ${{ toJSON(steps.k8s.outputs.url) }}
}
Expand Down
36 changes: 24 additions & 12 deletions .github/workflows/kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,32 @@ jobs:
uses: mikefarah/yq@v4.30.8
with:
cmd: yq '(.${{ github.event.deployment.payload.kubernetes.versionKey }} = "${{ needs.initialize.outputs.version }}")' -i remote/${{ inputs.deploymentRepoPath }}/values.yaml
- name: Commit deployment file
- name: Commit and push new image tag
run: |
set -euxo pipefail
cd remote
git config --global user.email "${{ inputs.botEmail }}"
git config --global user.name "${{ inputs.registryUsername }}"
git add .
git commit --allow-empty -m "chore(${{ github.event.deployment.payload.name }}): set ${{ github.event.deployment.payload.env }} version to ${{ needs.initialize.outputs.version }}"
- name: Push changes to ${{ inputs.deploymentRepoURL }} git repository
uses: ad-m/github-push-action@0fafdd62b84042d49ec0cb92d9cac7f7ce4ec79e
with:
repository: ${{ inputs.deploymentRepoURL }}
directory: remote
github_token: ${{ secrets.repoAccessToken }}
branch: main
git config user.email "$GIT_USER_EMAIL"
git config user.name "$GIT_USER_NAME"
git add ".chart/$ENV/values.yaml"
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "chore(deploy): set $ENV image tag to $VERSION"
if [ "$PUSH_TO_ENV_TAG" = "true" ]; then
echo "Set new image tag to $ENV"
NEW_SHA=$(git rev-parse HEAD)
git tag -fa "$ENV" -m "$ENV deploy $VERSION ($NEW_SHA)" "$NEW_SHA"
git push origin -f "refs/tags/$ENV"
else
git push origin main
fi
env:
GIT_USER_EMAIL: dev.bot@parcellab.com
GIT_USER_NAME: parcellab-dev-bot
ENV: ${{ github.event.deployment.payload.env }}
VERSION: ${{ needs.initialize.outputs.version }}
PUSH_TO_ENV_TAG: ${{ github.event.deployment.payload.pushToEnvTag }}
- if: success()
name: Successful ${{ github.event.deployment.payload.name }} deployment
uses: chrnorm/deployment-status@v2
Expand Down