From 8eddab90a3af4d517e4770956af153f7877c801e Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:57:58 +0530 Subject: [PATCH 01/10] Test argocd client github action --- .github/workflows/docker.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ed058d1..e6afca0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,10 +19,16 @@ jobs: username: ${{ secrets.DOCKERHUB_SIMPLEDOTORG_USERNAME }} password: ${{ secrets.DOCKERHUB_SIMPLEDOTORG_ACCESS_TOCKEN }} - - name: Build and push - uses: docker/build-push-action@v5 + # - name: Build and push + # uses: docker/build-push-action@v5 + # with: + # context: . + # file: ./Dockerfile + # push: true + # tags: simpledotorg/rtsl_exporter:${{ github.sha }}, simpledotorg/rtsl_exporter:latest + + - uses: clowdhaus/argo-cd-action/@main with: - context: . - file: ./Dockerfile - push: true - tags: simpledotorg/rtsl_exporter:${{ github.sha }}, simpledotorg/rtsl_exporter:latest + version: 2.6.7 + command: version + options: --client From 4a31d11bae71dc53cfd7960884e15d3e8be36f49 Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:00:10 +0530 Subject: [PATCH 02/10] Run action on current branch push --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e6afca0..a9b6181 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,6 +5,7 @@ on: push: branches: - 'master' + - 'add-cd' jobs: docker: From 347aa7c68adbc23d5d9c04fc6b0984c9639dd3ce Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:22:43 +0530 Subject: [PATCH 03/10] Test argocd login --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a9b6181..c55eb03 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -31,5 +31,5 @@ jobs: - uses: clowdhaus/argo-cd-action/@main with: version: 2.6.7 - command: version - options: --client + command: login ${{ secrets.SANDBOX_ARGOCD_ENDPOINT }} + options: --username ${{ secrets.SANDBOX_ARGOCD_USERNAME }} --password ${{ secrets.SANDBOX_ARGOCD_PASSWORD }} From 73386fc70c6bba15249b89f14f943b46e70b8182 Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:36:43 +0530 Subject: [PATCH 04/10] Fix argocd login command --- .github/workflows/docker.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c55eb03..9544b76 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -31,5 +31,4 @@ jobs: - uses: clowdhaus/argo-cd-action/@main with: version: 2.6.7 - command: login ${{ secrets.SANDBOX_ARGOCD_ENDPOINT }} - options: --username ${{ secrets.SANDBOX_ARGOCD_USERNAME }} --password ${{ secrets.SANDBOX_ARGOCD_PASSWORD }} + command: login ${{ secrets.SANDBOX_ARGOCD_ENDPOINT }} --username ${{ secrets.SANDBOX_ARGOCD_USERNAME }} --password ${{ secrets.SANDBOX_ARGOCD_PASSWORD }} From 8277fb58ab8348811c824a4621d4bc3a47c6334f Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:46:41 +0530 Subject: [PATCH 05/10] Fix a typo and pin arcod client version --- .github/workflows/docker.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9544b76..a8d6802 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,5 +30,6 @@ jobs: - uses: clowdhaus/argo-cd-action/@main with: - version: 2.6.7 - command: login ${{ secrets.SANDBOX_ARGOCD_ENDPOINT }} --username ${{ secrets.SANDBOX_ARGOCD_USERNAME }} --password ${{ secrets.SANDBOX_ARGOCD_PASSWORD }} + version: 2.7.3 + command: login ${{ secrets.SANDBOX_ARGOCD_ENDPOINT }} + options: --username ${{ secrets.ARGOCD_USERNAME }} --password ${{ secrets.SANDBOX_ARGOCD_PASSWORD }} From bdd507eb7744cad70b459bb1e79cab25a2f64f69 Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:56:06 +0530 Subject: [PATCH 06/10] Add app list command Test --- .github/workflows/docker.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a8d6802..737cae3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -33,3 +33,7 @@ jobs: version: 2.7.3 command: login ${{ secrets.SANDBOX_ARGOCD_ENDPOINT }} options: --username ${{ secrets.ARGOCD_USERNAME }} --password ${{ secrets.SANDBOX_ARGOCD_PASSWORD }} + - uses: clowdhaus/argo-cd-action/@main + with: + version: 2.7.3 + command: app list From 1ef33255c1832114eb44a9c9877ef979394b18aa Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:50:43 +0530 Subject: [PATCH 07/10] Deploy to sandbox with gitsha as tag --- .github/workflows/docker.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 737cae3..d147360 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,13 +20,13 @@ jobs: username: ${{ secrets.DOCKERHUB_SIMPLEDOTORG_USERNAME }} password: ${{ secrets.DOCKERHUB_SIMPLEDOTORG_ACCESS_TOCKEN }} - # - name: Build and push - # uses: docker/build-push-action@v5 - # with: - # context: . - # file: ./Dockerfile - # push: true - # tags: simpledotorg/rtsl_exporter:${{ github.sha }}, simpledotorg/rtsl_exporter:latest + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: simpledotorg/rtsl_exporter:${{ github.sha }}, simpledotorg/rtsl_exporter:latest - uses: clowdhaus/argo-cd-action/@main with: @@ -36,4 +36,8 @@ jobs: - uses: clowdhaus/argo-cd-action/@main with: version: 2.7.3 - command: app list + command: app set rtsl-exporter --helm-set image.tag=${{ github.sha }} + - uses: clowdhaus/argo-cd-action/@main + with: + version: 2.7.3 + command: app wait rtsl-exporter --timeout 600 From 47e6a90fc7828fce443584d188a06792ea9d9455 Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:16:30 +0530 Subject: [PATCH 08/10] Add test and deploy stage --- .github/workflows/docker.yml | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d147360..b92b493 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,25 +1,39 @@ - -name: Build and publish docker image +name: Test, build and deploy on: push: branches: - 'master' - 'add-cd' + pull_request: + branches: + - '*' jobs: - docker: + test: runs-on: ubuntu-latest steps: - name: Check out the repo uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21.1' + - name: Run tests + run: go test ./... -v + build: + needs: test + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/add-cd' + steps: + - name: Check out the repo + uses: actions/checkout@v4 - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_SIMPLEDOTORG_USERNAME }} password: ${{ secrets.DOCKERHUB_SIMPLEDOTORG_ACCESS_TOCKEN }} - - name: Build and push uses: docker/build-push-action@v5 with: @@ -27,7 +41,12 @@ jobs: file: ./Dockerfile push: true tags: simpledotorg/rtsl_exporter:${{ github.sha }}, simpledotorg/rtsl_exporter:latest - + + deploy: + needs: build + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/add-cd' + steps: - uses: clowdhaus/argo-cd-action/@main with: version: 2.7.3 From 19f5a4d4def57f7f405ed58632bc750ff135f427 Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:22:43 +0530 Subject: [PATCH 09/10] Update go setup action to v5 --- .github/workflows/{docker.yml => cicd.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{docker.yml => cicd.yml} (98%) diff --git a/.github/workflows/docker.yml b/.github/workflows/cicd.yml similarity index 98% rename from .github/workflows/docker.yml rename to .github/workflows/cicd.yml index b92b493..4900447 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/cicd.yml @@ -16,7 +16,7 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.21.1' - name: Run tests From 2b3b800ebcd7a4d74bc2cda28ee5153b2a1a3803 Mon Sep 17 00:00:00 2001 From: roypeter <16620459+roypeter@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:32:10 +0530 Subject: [PATCH 10/10] Move test stage to a new file --- .github/workflows/{cicd.yml => cd.yml} | 19 +------------------ .github/workflows/test.yml | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 18 deletions(-) rename .github/workflows/{cicd.yml => cd.yml} (79%) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cd.yml similarity index 79% rename from .github/workflows/cicd.yml rename to .github/workflows/cd.yml index 4900447..56787f2 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cd.yml @@ -1,29 +1,12 @@ -name: Test, build and deploy +name: Build and deploy on: push: branches: - 'master' - - 'add-cd' - pull_request: - branches: - - '*' jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.21.1' - - name: Run tests - run: go test ./... -v - build: - needs: test runs-on: ubuntu-latest if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/add-cd' steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d876df5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: Test + +on: + pull_request: + branches: + - '*' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.1' + - name: Run tests + run: go test ./... -v