Add postcommit PR workflow yaml. #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tag on merge | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: "us-docker.pkg.dev" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ vars.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_TOKEN }} | |
- name: Get latest release | |
id: get_latest_release | |
uses: joutvhu/get-release@v1 | |
with: | |
latest: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set tag | |
id: set_tag | |
run: | | |
RELEASE_TAG=$(date +%Y.%m) | |
latest_tag=${{ steps.get_latest_release.outputs.tag_name }} | |
major="$(echo $latest_tag | cut -d '.' -f 1)" | |
minor="$(echo $latest_tag | cut -d '.' -f 2)" | |
[ "$RELEASE_TAG" == "$major.$minor" ] && patch=$(echo $latest_tag | sed -e "s/^$RELEASE_TAG.\(.*\)/\1/") | |
[ -n "$patch" ] && patch=$((patch+1)) || patch=0 | |
RELEASE_TAG="$RELEASE_TAG.$patch" | |
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV | |
echo "BUILD_TAG=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
- name: Build | |
id: bake | |
uses: docker/bake-action@v5 | |
with: | |
source: "{{defaultContext}}:docker" | |
push: true | |
files: | | |
./docker-bake.hcl | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Update helm chart | |
id: update_helm_chart | |
run: | | |
sed -ie "s/^version:.*/version:\ ${{ env.RELEASE_TAG }}/" charts/identity-platform/Chart.yaml | |
sed -ie "s/^appVersion:.*/appVersion:\ ${{ env.RELEASE_TAG }}/" charts/identity-platform/Chart.yaml | |
sed -ie "s/tag:\ latest/tag:\ \"${{ env.BUILD_TAG }}\"/g" charts/identity-platform/values.yaml | |
- name: Run chart-releaser | |
uses: helm/chart-releaser-action@v1.6.0 | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
with: | |
charts_dir: charts | |
pages_branch: gh-pages | |
- name: Create tag | |
id: tag_version | |
uses: mathieudutour/github-tag-action@v6.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ env.RELEASE_TAG }} | |
tag_prefix: "" | |
- name: Touch CHANGELOG.md | |
run: | | |
touch CHANGELOG.md | |
- name: Create GitHub release | |
id: create_github_release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.tag_version.outputs.new_tag }} | |
name: ${{ steps.tag_version.outputs.new_tag }} | |
bodyFile: CHANGELOG.md | |
generateReleaseNotes: true | |
makeLatest: true | |
- name: Send Slack release notification | |
uses: slackapi/slack-github-action@v2.0.0 | |
with: | |
webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
webhook-type: webhook-trigger | |
payload: | | |
msg: "${{ steps.create_github_release.outputs.html_url }}" | |
- name: Set helm chart URL | |
id: set_helm_chart_url | |
run: | | |
echo "HELM_RELEASE_URL=${{ steps.create_github_release.outputs.html_url }}" | sed -e "s/${{ env.RELEASE_TAG }}/identity-platform-${{ env.RELEASE_TAG }}/" >>$GITHUB_ENV | |
- name: Send Slack helm release notification | |
uses: slackapi/slack-github-action@v2.0.0 | |
with: | |
webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
webhook-type: webhook-trigger | |
payload: | | |
msg: "${{ env.HELM_RELEASE_URL }}" | |