setting up argo with kustomize for dev environment #26
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: Main | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
detect_changes: | |
name: Detect What Changes Occurred | |
runs-on: ubuntu-latest | |
# Set job outputs to values from filter step | |
outputs: | |
bump_app: ${{ steps.filter.outputs.bump_app }} | |
version_file: ${{ steps.filter.outputs.version_file }} | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
bump_app: | |
- 'cmd/**' | |
- 'internal/**' | |
- 'api/**' | |
- 'config/**' | |
version_file: | |
- 'cmd/package.json' | |
bump_build_push: | |
needs: detect_changes | |
if: needs.detect_changes.outputs.bump_app == 'true' && needs.detect_changes.outputs.version_file == 'false' | |
name: Bump Application Version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Bump Application Version in package.json | |
id: version-bump-app | |
uses: 'phips28/gh-action-bump-version@master' | |
with: | |
major-wording: 'major,MAJOR,breaking' | |
minor-wording: 'feat,FEAT,minor,MINOR' | |
patch-wording: 'fix,chore,test,docs,style,refactor,patch' | |
rc-wording: 'RELEASE,alpha' | |
skip-commit: 'true' | |
skip-tag: 'true' | |
skip-push: 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PACKAGEJSON_DIR: 'cmd' | |
- name: New Version Output | |
env: | |
NEW_TAG: ${{ steps.version-bump-app.outputs.newTag }} | |
run: echo "New version $NEW_TAG" | |
- name: Retrieve Docker Image Name and Tag | |
run: | | |
echo "IMG_NAME=$(make docker_img_name)" >> $GITHUB_OUTPUT | |
echo "IMG_TAG=$(make docker_img_tag)" >> $GITHUB_OUTPUT | |
id: img_name_and_version_tag | |
- name: Setup Kustomize | |
uses: imranismail/setup-kustomize@v2 | |
with: | |
kustomize-version: "5.1.1" | |
- name: Update Container Image and Tag for Dev Environment | |
run: | | |
cd argo/dev | |
kustomize edit set image controller=${{ steps.img_name_and_version_tag.outputs.IMG_NAME }}:${{ steps.img_name_and_version_tag.outputs.IMG_TAG }} | |
cat kustomization.yaml | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Publish Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.img_name_and_version_tag.outputs.IMG_NAME }}:${{ steps.img_name_and_version_tag.outputs.IMG_TAG }},${{ steps.img_name_and_version_tag.outputs.IMG_NAME }}:latest | |
- name: Commit Files | |
run: | | |
git config --local user.email "sitedeployaction@users.noreply.github.com" | |
git config --local user.name "GitHub Action" | |
git commit -am 'CI(version) ${{ steps.version-bump-app.outputs.newTag }}' | |
git tag ${{ steps.version-bump-app.outputs.newTag }} | |
- name: Push Changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GH_TOKEN }} | |
branch: main | |
tags: true |