Skip to content

Commit

Permalink
Updating to work with argo
Browse files Browse the repository at this point in the history
  • Loading branch information
BobJWalker committed Apr 4, 2024
1 parent 567ca5c commit 880ee41
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 34 deletions.
45 changes: 23 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ on:
- 'src/**'
- '.github/workflows/build.yml'
workflow_dispatch:
env:
OCTOPUS_PROJECT_NAME: "Random Quotes"
OCTOPUS_FEATURE_BRANCH_CHANNEL: Default
OCTOPUS_RELEASE_CHANNEL: Release
OCTOPUS_SPACE: Default
OCTOPUS_API_KEY: ${{ secrets.OCTOPUSSERVERAPIKEY }}
OCTOPUS_URL: http://bobjwalker.octopus.app

jobs:
build-and-push-application:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -62,18 +54,27 @@ jobs:
- 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=${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }} --tag bobjwalker99/randomquotes-k8s:${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }} --tag bobjwalker99/randomquotes-k8s:latest .
- name: push build information to Octopus
uses: OctopusDeploy/push-build-information-action@v3
with:
packages: |
RandomQuotes-K8s
version: "${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }}"
- name: create release
uses: OctopusDeploy/create-release-action@v3
docker buildx build --push --platform linux/amd64,linux/arm64 -f "./RandomQuotes.Web/Dockerfile" --build-arg APP_VERSION=${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }} --tag bobjwalker99/randomquotes-k8s:${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }} --tag bobjwalker99/randomquotes-k8s:latest .
- name: update kustomize overlay
uses: mikefarah/yq@master
with:
project: ${{ env.OCTOPUS_PROJECT_NAME }}
channel: ${{ github.ref == 'refs/heads/main' && env.OCTOPUS_RELEASE_CHANNEL || env.OCTOPUS_FEATURE_BRANCH_CHANNEL }}
release_number: "${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }}${{ env.GitVersion_PreReleaseLabelWithDash }}"
package_version: "${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }}${{ env.GitVersion_PreReleaseLabelWithDash }}"
cmd: yq -i '.images.[0].newTag = "${{ steps.determine_version.outputs.semVer }}"' 'k8s/overlays/${{ github.ref == 'refs/heads/main' && 'test' || 'dev' }}/kustomization.yaml'
- id: commit_kustomize_change
name: commit 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/${{ github.ref == 'refs/heads/main' && 'test' || 'dev' }}/kustomization.yaml'
git commit -am "Updating ${{ github.ref == 'refs/heads/main' && 'test' || 'dev' }} overlay file to ${{ steps.determine_version.outputs.semVer }}"
git push --set-upstream origin ${GITHUB_REF:11}
echo "The current branch is ${{ github.ref }}"
if [[ "${{ github.ref }}" != "refs/head/main" ]]; then
echo "The current branch is not the main branch, updating the dev-argo tag"
git tag 'dev-argo' --force
git push origin 'dev-argo' --force
else
echo "The curent branch is the main branch, leaving the dev-argo tag alone"
fi
4 changes: 2 additions & 2 deletions k8s/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: development
namespace: development-randomquotes
resources:
- ../../base
images:
- name: bobjwalker99/randomquotes-k8s
newName: bobjwalker99/randomquotes-k8s
newTag: "#{Project.Container.RandomQuotesVersion}"
newTag: "0.1.79.1"
patches:
- target:
kind: Ingress
Expand Down
4 changes: 2 additions & 2 deletions k8s/overlays/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: production
namespace: production-randomquotes
resources:
- ../../base
images:
- name: bobjwalker99/randomquotes-k8s
newName: bobjwalker99/randomquotes-k8s
newTag: "#{Project.Container.RandomQuotesVersion}"
newTag: "0.1.79.1"

patches:
- target:
Expand Down
4 changes: 2 additions & 2 deletions k8s/overlays/staging/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: staging
namespace: staging-randomquotes
resources:
- ../../base

images:
- name: bobjwalker99/randomquotes-k8s
newName: bobjwalker99/randomquotes-k8s
newTag: "#{Project.Container.RandomQuotesVersion}"
newTag: "0.1.79.1"

patches:
- target:
Expand Down
4 changes: 2 additions & 2 deletions k8s/overlays/test/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: test
namespace: test-randomquotes
resources:
- ../../base

images:
- name: bobjwalker99/randomquotes-k8s
newName: bobjwalker99/randomquotes-k8s
newTag: "#{Project.Container.RandomQuotesVersion}"
newTag: "0.1.79.1"
patches:
- target:
kind: Ingress
Expand Down
8 changes: 4 additions & 4 deletions k8s/provision/namespaces.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
apiVersion: v1
kind: Namespace
metadata:
name: development
name: development-randomquotes
---
apiVersion: v1
kind: Namespace
metadata:
name: test
name: test-randomquotes
---
apiVersion: v1
kind: Namespace
metadata:
name: staging
name: staging-randomquotes
---
apiVersion: v1
kind: Namespace
metadata:
name: production
name: production-randomquotes

0 comments on commit 880ee41

Please sign in to comment.