Skip to content

Commit

Permalink
add deploy job
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitiwat-owen committed Nov 11, 2023
1 parent 761a298 commit 2fe473f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
38 changes: 37 additions & 1 deletion .github/workflows/build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

GITOPS_REPO: CUSportGo/sport-go-gitops
GITOPS_APPLICATION_NAME: account

jobs:
test:
Expand Down Expand Up @@ -121,4 +122,39 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
needs:
- test
- build
steps:
- uses: actions/checkout@v3
with:
repository: ${{ env.GITOPS_REPO }}
token: ${{ secrets.GH_PAT }}

- id: string
uses: ASzc/change-string-case-action@v1
with:
string: ${{ needs.build.outputs.IMAGE_NAME }}

- name: Setup Kustomize
uses: imranismail/setup-kustomize@v2

- name: Update image version
working-directory: ${{ env.GITOPS_APPLICATION_NAME }}/overlays/${{ github.ref_name }}
run: |
kustomize edit set image ${{ steps.string.outputs.lowercase }}=${{ steps.string.outputs.lowercase }}:${{ needs.build.outputs.IMAGE_TAG }}
- name: Commit and push changes
uses: actions-js/push@master
with:
message: "chore: set `${{ env.GITOPS_APPLICATION_NAME }}` image tag to `${{ needs.build.outputs.IMAGE_TAG }}` in `${{ github.ref_name }}`"
github_token: ${{ secrets.GH_PAT }}
repository: ${{ env.GITOPS_REPO }}
force: true
branch: main
4 changes: 0 additions & 4 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Build test
on:
push:
branches:
- dev
- main
pull_request:
branches:
- dev
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Run unit test
on:
push:
branches:
- dev
- main
pull_request:
branches:
- dev
Expand Down

0 comments on commit 2fe473f

Please sign in to comment.