Update Stage App name #4
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: Argo CD Sync | |
on: | |
push: | |
branches: | |
- main | |
- master | |
jobs: | |
build: | |
name: "π¦ Build docker image and push to Amazon ECR" | |
runs-on: ubuntu-latest | |
env: | |
APP_NAME: hello-world-api-dotnet | |
timeout-minutes: 10 | |
steps: | |
- name: "π§ Add dynamic envs" | |
run: | | |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | |
echo "SHA= ${GITHUB_SHA}" | |
echo "SHORT SHA= ${SHORT_SHA}" | |
- name: "βοΈ checkout repository" | |
uses: actions/checkout@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: "π Login to Amazon ECR π" | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: "π¦π Build, tag, and push docker image to Amazon ECR" | |
env: | |
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
REPOSITORY: "hello-world-api-dotnet" | |
IMAGE_TAG: ${{ env.SHORT_SHA }} | |
run: | | |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . | |
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG | |
update-image-stage: | |
name: "π Update STAGE image tag" | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
timeout-minutes: 10 | |
steps: | |
- name: "π§ Add dynamic envs" | |
id: "image-tag" | |
run: | | |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | |
echo "SHA= ${GITHUB_SHA}" | |
echo "SHORT SHA= ${SHORT_SHA}" | |
echo "::set-output name=version::$SHORT_SHA" | |
- name: Checkout Target Repository | |
uses: actions/checkout@v3 | |
with: | |
repository: "OpsVerseIO/deployment-manifests" | |
path: main | |
token: ${{ secrets.GH_PAT }} | |
- name: "π Update Image tag Version in the DEV manifest file" | |
uses: OpsVerseIO/[email protected] | |
with: | |
repository: "OpsVerseIO/deployment-manifests" | |
valueFile: 'hello-world-api-dotnet/helm/stage/values.yaml' | |
propertyPath: 'helloworldapidotnet.image.tag' | |
value: '${{ env.SHORT_SHA }}' | |
branch: main | |
createPR: false | |
message: '[STAGE] Update Image tag of hello-world-api-dotnet' | |
token: ${{ secrets.GH_PAT }} | |
workDir: main | |
masterBranchName: main | |
targetBranch: main | |
force: true | |
updateFile: true | |
release-stage: | |
name: "π Deploy to STAGE (ArgoCD Sync)" | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- update-image-stage | |
timeout-minutes: 10 | |
steps: | |
- name: "π§ Trigger ArgoCD Sync/Deployment in STAGE" | |
uses: opsverseio/[email protected] | |
with: | |
address: ${{ secrets.ARGOCD_SERVER }} | |
token: ${{ secrets.ARGOCD_TOKEN }} | |
action: sync | |
appName: ${{ secrets.ARGOCD_STAGE_APP_NAME }} | |
disableTlsVerification: "true" | |
- name: "π Deploy to STAGE" | |
run: | | |
echo "β³ Deploying the application to STAGE" | |
echo "πβ π Successfully synced STAGE ArgoCD and deployed the application to STAGE" |