From b1a9b51358673de27e03462ffd8f376ef3182d02 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Jan 2024 10:47:01 +0700 Subject: [PATCH 1/9] =?UTF-8?q?test=20=E0=B9=81=E0=B8=81=E0=B9=89=20versio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3ea8a995e..246bc9fab 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,10 +30,10 @@ jobs: else IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} fi - if [[ $IMAGE_VER == '' ]]; then + if [[ secrets.IMAGE_VER == '' ]]; then IMAGE_VER='test-vBeta' fi - echo '::set-output name=image_ver::'$IMAGE_VER + echo '::set-output name=image_ver::'secrets.IMAGE_VER - name: Check Version run: | echo $GITHUB_REF From b28a92c737b950e619d7aa0480c5427b1544d29e Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Jan 2024 11:14:09 +0700 Subject: [PATCH 2/9] no message --- .github/workflows/release.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 246bc9fab..ba7c5bda1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,10 +30,10 @@ jobs: else IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} fi - if [[ secrets.IMAGE_VER == '' ]]; then - IMAGE_VER='test-vBeta' - fi - echo '::set-output name=image_ver::'secrets.IMAGE_VER + # if [[ $IMAGE_VER == '' ]]; then + # IMAGE_VER='test-vBeta' + # fi + echo '::set-output name=image_ver::'$IMAGE_VER - name: Check Version run: | echo $GITHUB_REF From 7e7e54956fbafc9ca9c05e91901ae77b43efce20 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Jan 2024 11:17:09 +0700 Subject: [PATCH 3/9] test build --- .github/workflows/release.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ba7c5bda1..895c0a12c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,9 +30,6 @@ jobs: else IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} fi - # if [[ $IMAGE_VER == '' ]]; then - # IMAGE_VER='test-vBeta' - # fi echo '::set-output name=image_ver::'$IMAGE_VER - name: Check Version run: | From 2ac7a86cbeed58b58d3aa06519cc135c8899d360 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Jan 2024 11:51:49 +0700 Subject: [PATCH 4/9] test build --- .github/workflows/release.yaml | 51 +--------------------------------- 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 895c0a12c..a662b2373 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,35 +22,6 @@ jobs: - uses: actions/checkout@v3 # skip Set up QEMU because it fail on act and container # Gen Version try to get version from tag or inut - - name: Gen Version - id: gen_ver - run: | - if [[ $GITHUB_REF == 'refs/tags/'* ]]; then - IMAGE_VER='${GITHUB_REF/refs\/tags\//}' - else - IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} - fi - echo '::set-output name=image_ver::'$IMAGE_VER - - name: Check Version - run: | - echo $GITHUB_REF - echo ${{ steps.gen_ver.outputs.image_ver }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login in to registry - uses: docker/login-action@v2 - with: - registry: ${{env.REGISTRY}} - username: ${{secrets.DOCKER_USER}} - password: ${{secrets.DOCKER_PASS}} - - name: Build and push docker image - uses: docker/build-push-action@v3 - with: - context: . - platforms: linux/amd64 - push: true - tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest - name: Remote Deployment uses: appleboy/ssh-action@v0.1.8 with: @@ -60,24 +31,4 @@ jobs: port: 22 script: | cd "${{env.COMPOSE_PATH}}" - docker-compose pull - docker-compose up -d - echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - uses: snow-actions/line-notify@v1.1.0 - if: success() - with: - access_token: ${{ env.TOKEN_LINE }} - message: | - -Success✅✅✅ - Image: ${{env.IMAGE_NAME}} - Version: ${{ github.event.inputs.IMAGE_VER }} - By: ${{secrets.DOCKER_USER}} - - uses: snow-actions/line-notify@v1.1.0 - if: failure() - with: - access_token: ${{ env.TOKEN_LINE }} - message: | - -Failure❌❌❌ - Image: ${{env.IMAGE_NAME}} - Version: ${{ github.event.inputs.IMAGE_VER }} - By: ${{secrets.DOCKER_USER}} + echo "tag=${GITHUB_REF#refs/*/}"> success From 87080cab340f8ee6669b51b6d74c5b64ccc4bcd0 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Jan 2024 11:54:31 +0700 Subject: [PATCH 5/9] build --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a662b2373..b87e6d40c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,4 +31,4 @@ jobs: port: 22 script: | cd "${{env.COMPOSE_PATH}}" - echo "tag=${GITHUB_REF#refs/*/}"> success + echo "tag=${{GITHUB_REF#refs/*/}}"> success From faba45ce5c786a824049c295bfd4f6d7cc13af9b Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Jan 2024 11:58:30 +0700 Subject: [PATCH 6/9] build --- .github/workflows/release.yaml | 54 +++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b87e6d40c..3ea8a995e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,6 +22,38 @@ jobs: - uses: actions/checkout@v3 # skip Set up QEMU because it fail on act and container # Gen Version try to get version from tag or inut + - name: Gen Version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER='${GITHUB_REF/refs\/tags\//}' + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo '::set-output name=image_ver::'$IMAGE_VER + - name: Check Version + run: | + echo $GITHUB_REF + echo ${{ steps.gen_ver.outputs.image_ver }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login in to registry + uses: docker/login-action@v2 + with: + registry: ${{env.REGISTRY}} + username: ${{secrets.DOCKER_USER}} + password: ${{secrets.DOCKER_PASS}} + - name: Build and push docker image + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest - name: Remote Deployment uses: appleboy/ssh-action@v0.1.8 with: @@ -31,4 +63,24 @@ jobs: port: 22 script: | cd "${{env.COMPOSE_PATH}}" - echo "tag=${{GITHUB_REF#refs/*/}}"> success + docker-compose pull + docker-compose up -d + echo "${{ steps.gen_ver.outputs.image_ver }}"> success + - uses: snow-actions/line-notify@v1.1.0 + if: success() + with: + access_token: ${{ env.TOKEN_LINE }} + message: | + -Success✅✅✅ + Image: ${{env.IMAGE_NAME}} + Version: ${{ github.event.inputs.IMAGE_VER }} + By: ${{secrets.DOCKER_USER}} + - uses: snow-actions/line-notify@v1.1.0 + if: failure() + with: + access_token: ${{ env.TOKEN_LINE }} + message: | + -Failure❌❌❌ + Image: ${{env.IMAGE_NAME}} + Version: ${{ github.event.inputs.IMAGE_VER }} + By: ${{secrets.DOCKER_USER}} From 4a2e395692f3046753cd4206849429565226e0e8 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Jan 2024 12:13:33 +0700 Subject: [PATCH 7/9] set auto build --- .github/workflows/build-local.yaml | 39 ------------------------------ .github/workflows/release.yaml | 5 ++-- 2 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/build-local.yaml diff --git a/.github/workflows/build-local.yaml b/.github/workflows/build-local.yaml deleted file mode 100644 index 973c40ff9..000000000 --- a/.github/workflows/build-local.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# use for local build with act -name: build-local -run-name: build-local ${{ github.actor }} -on: - workflow_dispatch: -env: - REGISTRY: docker.frappet.com - IMAGE_NAME: demo/bma-ehr-app -jobs: - # act workflow_dispatch -W .github/workflows/build-local.yaml --input IMAGE_VER=test-v1 - build-local: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - # skip Set up QEMU because it fail on act and container - - name: Gen Version - id: gen_ver - run: | - if [[ $GITHUB_REF == 'refs/tags/'* ]]; then - IMAGE_VER='${GITHUB_REF/refs\/tags\//}' - else - IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} - fi - if [[ $IMAGE_VER == '' ]]; then - IMAGE_VER='test-vBeta' - fi - echo '::set-output name=image_ver::'$IMAGE_VER - - name: Test Version - run: | - echo $GITHUB_REF - echo ${{ steps.gen_ver.outputs.image_ver }} - - - name: Build and load local docker image - uses: docker/build-push-action@v3 - with: - context: . - platforms: linux/amd64 - load: true - tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3ea8a995e..d73eb3681 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -13,7 +13,6 @@ env: IMAGE_NAME: ehr/bma-ehr-app DEPLOY_HOST: frappet.com COMPOSE_PATH: /home/frappet/docker/bma-ehr - TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0 jobs: # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd release-test: @@ -69,7 +68,7 @@ jobs: - uses: snow-actions/line-notify@v1.1.0 if: success() with: - access_token: ${{ env.TOKEN_LINE }} + access_token: ${{ secrets.TOKEN_LINE }} message: | -Success✅✅✅ Image: ${{env.IMAGE_NAME}} @@ -78,7 +77,7 @@ jobs: - uses: snow-actions/line-notify@v1.1.0 if: failure() with: - access_token: ${{ env.TOKEN_LINE }} + access_token: ${{ secrets.TOKEN_LINE }} message: | -Failure❌❌❌ Image: ${{env.IMAGE_NAME}} From 7cf17b4adf43f4c3dc683533a69bdb8d78e2f4b1 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Jan 2024 12:56:19 +0700 Subject: [PATCH 8/9] test auto build --- .github/workflows/release.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d73eb3681..466cd9617 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,12 +1,9 @@ name: release-test run-name: release-test ${{ github.actor }} on: - # push: - # tags: - # - 'v[0-9]+.[0-9]+.[0-9]+' - # tags-ignore: - # - '2.*' - # Allow run workflow manually from Action tab + push: + tags: + - "version-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com @@ -21,16 +18,19 @@ jobs: - uses: actions/checkout@v3 # skip Set up QEMU because it fail on act and container # Gen Version try to get version from tag or inut + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - name: Gen Version id: gen_ver run: | if [[ $GITHUB_REF == 'refs/tags/'* ]]; then - IMAGE_VER='${GITHUB_REF/refs\/tags\//}' + IMAGE_VER=${{ steps.vars.outputs.tag }} else IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} fi if [[ $IMAGE_VER == '' ]]; then - IMAGE_VER='test-vBeta' + IMAGE_VER=${{ steps.vars.outputs.tag }} fi echo '::set-output name=image_ver::'$IMAGE_VER - name: Check Version From c48bbe2a173961755b722ec895a33c008c169426 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 11 Jan 2024 13:04:18 +0700 Subject: [PATCH 9/9] add tag version to line --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 466cd9617..63d4f6c70 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -72,7 +72,7 @@ jobs: message: | -Success✅✅✅ Image: ${{env.IMAGE_NAME}} - Version: ${{ github.event.inputs.IMAGE_VER }} + Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} By: ${{secrets.DOCKER_USER}} - uses: snow-actions/line-notify@v1.1.0 if: failure() @@ -81,5 +81,5 @@ jobs: message: | -Failure❌❌❌ Image: ${{env.IMAGE_NAME}} - Version: ${{ github.event.inputs.IMAGE_VER }} + Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} By: ${{secrets.DOCKER_USER}}