Let's just do some manual git commands #45
Workflow file for this run
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: Build Container | |
on: | |
push: | |
branches: | |
- main | |
- 'feature/**' | |
paths: | |
- 'src/**' | |
- '.github/workflows/build.yml' | |
workflow_dispatch: | |
jobs: | |
build-and-push-application: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
dotnet-version: ['8.0.x'] | |
steps: | |
- uses: actions/checkout@v1 | |
with: | |
fetch-depth: '0' | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ matrix.dotnet-version }} | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: 5.x | |
- id: determine_version | |
name: Determine Version | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
additionalArguments: /overrideconfig mode=Mainline | |
- name: update tag with latest version | |
uses: richardsimko/update-tag@v1 | |
with: | |
tag_name: ${{ steps.determine_version.outputs.semVer }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_PAT_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PAT }} | |
- name: install buildx | |
id: buildx | |
uses: crazy-max/ghaction-docker-buildx@v1 | |
with: | |
version: latest | |
- name: build and push website container | |
working-directory: src | |
run: | | |
docker buildx build --push --platform linux/amd64,linux/arm64 -f "./RandomQuotes.Web/Dockerfile" --build-arg APP_VERSION=${{ steps.determine_version.outputs.semVer }} --tag bobjwalker99/randomquotes-k8s:${{ steps.determine_version.outputs.semVer }} --tag bobjwalker99/randomquotes-k8s:latest . | |
- name: update dev kustomize overlay | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -i '.images.[0].newTag = "${{ steps.determine_version.outputs.semVer }}"' 'k8s/overlays/dev/kustomization.yaml' | |
if: contains(github.ref, 'feature') | |
- id: commit_dev_kustomize_change | |
name: commit the dev kustomize change | |
run : | | |
git config --global user.name '${{ github.actor }}' | |
git config --global user.email '${{ github.actor }}@users.noreply.github.com' | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
git checkout "${GITHUB_REF:11}" | |
git stage 'k8s/overlays/dev/kustomization.yaml' | |
git commit -am "Automated report" | |
git tag 'dev-argo' --force | |
git push | |
if: contains(github.ref, 'feature') | |
- name: update test kustomize overlay | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -i '.images.[0].newTag = "${{ steps.determine_version.outputs.semVer }}"' 'k8s/overlays/test/kustomization.yaml' | |
if: github.ref == 'refs/heads/main' | |
- id: commit_test_kustomize_change | |
name: commit the test kustomize change | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: 'k8s/overlays/test/kustomization.yaml' | |
message: 'Updating test overlay image tag to ${{ steps.determine_version.outputs.semVer }}' | |
if: github.ref == 'refs/heads/main' |