diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f0c9b12..f4258c8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,11 +1,11 @@ name: release -run-name: remote-build ${{ github.actor }} +run-name: release ${{ github.actor }} on: push: tags: - 'v[0-9]+.[0-9]+.[0-9]+' - # tags-ignore: - # - '2.*' + tags-ignore: + - '2.*' # Allow run workflow manually from Action tab workflow_dispatch: inputs: @@ -15,14 +15,15 @@ on: env: REGISTRY: docker.frappet.com IMAGE_NAME: demo/qualifying-exam-cms - # IMAGE_TAG: 0.2.1 jobs: - # export GITHUB_REF=refs/tags/v1.2.3 - # act workflow_dispatch --input IMAGE_VER=v0.2.1 -W .github/workflows/release.yaml -j release + # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=v0.2.1-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd release: runs-on: ubuntu-latest steps: - - name: Gen tags + # https://thekevinwang.com/2022/06/13/github-actions-survival-skills/ + - name: Check out code # checkout only cms is possible but I checkout all + uses: actions/checkout@v3 + - name: Gen Version id: gen_ver run: | if [[ $GITHUB_REF == 'refs/tags/'* ]]; then @@ -33,8 +34,39 @@ jobs: if [[ $IMAGE_VER == '' ]]; then IMAGE_VER='beta' fi + echo "{\"version\":\"$IMAGE_VER\", \"builddate\":\"$(date +"%Y-%m-%d_%T")\",\"ref_name\":\"$GITHUB_REF\" }" > ./cms/src/lib/ver.json + cat ./cms/src/lib/ver.json echo '::set-output name=image_ver::'$IMAGE_VER - - name: Test - run: | - echo $GITHUB_REF - echo ${{ steps.gen_ver.outputs.image_ver }} + # - name: Test Version + # run: | + # echo $GITHUB_REF + # echo ${{ steps.gen_ver.outputs.image_ver }} + # cat ./cms/src/lib/ver.json + - 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: CMS Build and push docker image + uses: docker/build-push-action@v3 + with: + context: cms + # platforms: linux/amd64,linux/arm64 + 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: + host: frappet.com + username: frappet + password: ${{ secrets.SSH_PASSWORD }} + port: 22 + script: | + cd /home/frappet/docker/bma-ehr-recruit-qualifying-exam + docker-compose pull + docker-compose up -d + touch success + diff --git a/.github/workflows/remote-build.yaml b/.github/workflows/remote-build.yaml index 612d343..3cedd59 100644 --- a/.github/workflows/remote-build.yaml +++ b/.github/workflows/remote-build.yaml @@ -3,12 +3,9 @@ run-name: remote-build ${{ github.actor }} on: # push: # tags: - # - v1.** - # branches: - # - 'main' - # branches: - # - 'release-*' - + # - 'v[0-9]+.[0-9]+.[0-9]+' + # tags-ignore: + # - '2.*' # Allow run workflow manually from Action tab workflow_dispatch: env: @@ -31,9 +28,10 @@ jobs: registry: ${{env.REGISTRY}} username: ${{secrets.DOCKER_USER}} password: ${{secrets.DOCKER_PASS}} - - uses: actions/setup-node@v3 - with: - node-version: '18' + # Node no need because use 2 state build + # - uses: actions/setup-node@v3 + # with: + # node-version: '18' - name: Build and push docker image uses: docker/build-push-action@v3 with: diff --git a/cms/.dockerignore b/cms/.dockerignore new file mode 100644 index 0000000..7614cf2 --- /dev/null +++ b/cms/.dockerignore @@ -0,0 +1,14 @@ +# .dockerignore +node_modules +.vscode +.git +.gitignore +.gitattributes +.eslintignore +.eslintrc.cjs +.prettierrc +.pretieriignore +README.md +Dockerfile +docker-compose.yaml +playwright.config.ts diff --git a/cms/README.md b/cms/README.md index 149bb2e..24b2ac4 100644 --- a/cms/README.md +++ b/cms/README.md @@ -12,7 +12,7 @@ - [Keycloak](https://www.keycloak.org/) ใช้สำหรับทำระบบ Login ## วีดีโอแสดงการทำงานทั้งหมด -[![Argo Workflows Basic](https://img.youtube.com/vi/WNNDuRjBDd4/0.jpg)](https://youtu.be/WNNDuRjBDd4 "Automate Development") +[![Automate Development](https://img.youtube.com/vi/7CER67WVWec/0.jpg)](https://youtu.be/7CER67WVWec "Automate Development") ในวีดีโอลืมแสดงตัวอย่างการใช้ API @@ -76,6 +76,7 @@ npm run test:unit - สร้าง Docker Image แล้ว Push ขึ้น Registry (docker.frappet.com) - ssh ไปที่ (192.168.1.9) เพื่อ pull image ตัวใหม่มาใช้ ถ้าจะรันบนเครื่องของเราเอง(local) ให้ติดตั้ง act + ``` bash # Install act (Windows) winget install nektos.act @@ -83,11 +84,12 @@ winget install nektos.act brew install act ``` - -- [ตัวอย่างการใช้งานในบริษัท](https://youtu.be/k1w_cCzCd0o) +- [ตัวอย่างการใช้งานกับ .NET](https://youtu.be/k1w_cCzCd0o) # CD Argo CD -TODO +TODO ยังไม่ได้ทำสำหรับโปรเจ็กนี้ แต่ก็ดูวิธีทำจาก +[ตัวอย่างการทำ CD ด้วย Argo CD](https://youtu.be/c7sSQLuhht0) ก่อนได้ครับ + ## PWA ใน [app.html](./src/app.html) จะเรียกใช้ [manifest.json](./src/static/manifest.json) diff --git a/cms/src/lib/ver.json b/cms/src/lib/ver.json new file mode 100644 index 0000000..aef5175 --- /dev/null +++ b/cms/src/lib/ver.json @@ -0,0 +1,5 @@ +{ + "version":"Auto gen version", + "builddate":"2020-02-02_22:22:22" + +} \ No newline at end of file diff --git a/cms/src/routes/about/+page.server.ts b/cms/src/routes/about/+page.server.ts index 0cb50e7..94b4c70 100644 --- a/cms/src/routes/about/+page.server.ts +++ b/cms/src/routes/about/+page.server.ts @@ -1,6 +1,5 @@ import {getContact} from "$lib/data/info" - import type { PageServerLoad } from './$types' /* export const load: PageServerLoad = async () => { @@ -8,5 +7,5 @@ export const load: PageServerLoad = async () => { }*/ export const load = (async () => { - return getContact() + return getContact() }) satisfies PageServerLoad diff --git a/cms/src/routes/about/+page.svelte b/cms/src/routes/about/+page.svelte index e6f5860..0313a17 100644 --- a/cms/src/routes/about/+page.svelte +++ b/cms/src/routes/about/+page.svelte @@ -1,10 +1,15 @@

{data.company_name}

{data.description}
+
{ver.version}
+
{ver.builddate}
+ +