From d79cdf1afd891623e205a8a53da434c5cafe7f00 Mon Sep 17 00:00:00 2001 From: "Ali(Ako) Hosseini" Date: Mon, 8 Jan 2024 12:46:28 +0800 Subject: [PATCH] ci: fix caching --- .github/actions/bundle_install/action.yml | 27 +++-- .../invalidate_master_cache/action.yml | 2 +- .github/workflows/release-production.yml | 102 +++++++++--------- .github/workflows/release-staging.yml | 56 +++++----- 4 files changed, 93 insertions(+), 94 deletions(-) diff --git a/.github/actions/bundle_install/action.yml b/.github/actions/bundle_install/action.yml index 4f92d379..ab564e95 100644 --- a/.github/actions/bundle_install/action.yml +++ b/.github/actions/bundle_install/action.yml @@ -3,18 +3,15 @@ description: Bundle Install runs: using: composite steps: - - restore_cache: - name: Bundle modules cache restore - keys: - - bundle-v1-{{ checksum "Gemfile" }} - - bundle-v1- - - bundle_install: - name: Bundle install - run: | - bundle install --path ./modules - - save_cache: - name: Bundle modules cache save - key: bundle-v1-{{ checksum "Gemfile" }} - with: - paths: - - "modules" + - name: Bundle modules cache restore + id: cache-modules + uses: actions/cache/restore@v3 + with: + path: ./modules + key: bundle-v1-{{ checksum "Gemfile" }} + + - name: Bundle install + if: steps.cache-modules.outputs.cache-hit != 'true' + shell: bash + run: bundle install --path ./modules + diff --git a/.github/actions/invalidate_master_cache/action.yml b/.github/actions/invalidate_master_cache/action.yml index f99d66a6..22ff6c0f 100644 --- a/.github/actions/invalidate_master_cache/action.yml +++ b/.github/actions/invalidate_master_cache/action.yml @@ -6,5 +6,5 @@ runs: - name: save_cache uses: actions/cache/save@v3 with: - path: ./node_modules + path: ./modules key: v1-deps-{{ checksum "Gemfile" }} diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml index fa4b313e..a913535c 100644 --- a/.github/workflows/release-production.yml +++ b/.github/workflows/release-production.yml @@ -1,55 +1,57 @@ name: Websocket Production Workflow on: push: - tags: - - production_* + branches: + - master jobs: - build_test_and_publish: - name: Build, Test and Publish to Production - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Bundle Install - uses: ./.github/actions/bundle_install - - name: Build Jekyll site - uses: ./.github/actions/build - - name: Versioning - uses: ./.github/actions/versioning - with: - release_type: production - - name: Publish to Cloudflare Pages Production - uses: "./.github/actions/publish_to_pages_production" - with: - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - - name: Build Docker image and push to Docker hub and K8S - uses: "./.github/actions/build_and_push_docker_image" - with: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} - K8S_NAMESPACE: "developers-binary-com-production" - KUBE_SERVER: ${{ secrets.KUBE_SERVER }} - SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - CA_CRT: ${{ secrets.CA_CRT }} - APP_VERSION: latest + build_test_and_publish: + name: Build, Test and Publish to Production + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Bundle Install + uses: ./.github/actions/bundle_install + - name: Build Jekyll site + uses: ./.github/actions/build + - name: invalidate master cache + uses: ./.github/actions/invalidate_master_cache + - name: Versioning + uses: ./.github/actions/versioning + with: + release_type: production + - name: Publish to Cloudflare Pages Production + uses: "./.github/actions/publish_to_pages_production" + with: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + - name: Build Docker image and push to Docker hub and K8S + uses: "./.github/actions/build_and_push_docker_image" + with: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} + K8S_NAMESPACE: "developers-binary-com-production" + KUBE_SERVER: ${{ secrets.KUBE_SERVER }} + SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} + CA_CRT: ${{ secrets.CA_CRT }} + APP_VERSION: latest + - send_slack_notification: - name: Send Slack notification - runs-on: ubuntu-latest - environment: Production - if: always() - needs: [build_test_and_publish] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Conclusion - uses: technote-space/workflow-conclusion-action@v3 - - name: Send Slack Notification - uses: "./.github/actions/send_slack_notifications" - with: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - status: ${{ env.WORKFLOW_CONCLUSION }} - release_type: Production - version: $GITHUB_REF_NAME + send_slack_notification: + name: Send Slack notification + runs-on: ubuntu-latest + if: always() + needs: [build_test_and_publish] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Conclusion + uses: technote-space/workflow-conclusion-action@v3 + - name: Send Slack Notification + uses: "./.github/actions/send_slack_notifications" + with: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + status: ${{ env.WORKFLOW_CONCLUSION }} + release_type: Production + version: $GITHUB_REF_NAME diff --git a/.github/workflows/release-staging.yml b/.github/workflows/release-staging.yml index 05adda36..4573b4b3 100644 --- a/.github/workflows/release-staging.yml +++ b/.github/workflows/release-staging.yml @@ -1,36 +1,36 @@ name: Websocket Staging Workflow on: - push: - branches: + push: + branches: - master jobs: build_test_and_publish: name: Build, Test and Publish to Staging runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Bundle Install - uses: ./.github/actions/bundle_install - - name: Build Jekyll site - uses: ./.github/actions/build - - name: Versioning - uses: ./.github/actions/versioning - with: - release_type: staging - - name: Publish to Cloudflare Pages Staging - uses: "./.github/actions/publish_to_pages_staging" - with: - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - - name: Build Docker image and push to Docker hub and K8S - uses: "./.github/actions/build_and_push_docker_image" - with: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} - K8S_NAMESPACE: "developers-binary-com-staging" - KUBE_SERVER: ${{ secrets.KUBE_SERVER }} - SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} - CA_CRT: ${{ secrets.CA_CRT }} - APP_VERSION: latest-staging + - name: Checkout + uses: actions/checkout@v4 + - name: Bundle Install + uses: ./.github/actions/bundle_install + - name: Build Jekyll site + uses: ./.github/actions/build + - name: Versioning + uses: ./.github/actions/versioning + with: + release_type: staging + - name: Publish to Cloudflare Pages Staging + uses: "./.github/actions/publish_to_pages_staging" + with: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + - name: Build Docker image and push to Docker hub and K8S + uses: "./.github/actions/build_and_push_docker_image" + with: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} + K8S_NAMESPACE: "developers-binary-com-staging" + KUBE_SERVER: ${{ secrets.KUBE_SERVER }} + SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} + CA_CRT: ${{ secrets.CA_CRT }} + APP_VERSION: latest-staging