From 3365b6bd620d2fadd3ac136993258aa68ee8b413 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Wed, 26 Jun 2024 13:26:47 +0100 Subject: [PATCH] =?UTF-8?q?refactor(changeset-cicd):=20=F0=9F=92=A1TIAS=20?= =?UTF-8?q?skip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(changeset-cicd): πŸ’‘TIAS skip --- .github/workflows/changeset-handler.yml | 129 ++++++++++++++++++ .../changeset-version-management.yml | 126 ++++++++++------- 2 files changed, 202 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/changeset-handler.yml diff --git a/.github/workflows/changeset-handler.yml b/.github/workflows/changeset-handler.yml new file mode 100644 index 0000000..ca887c7 --- /dev/null +++ b/.github/workflows/changeset-handler.yml @@ -0,0 +1,129 @@ +name: πŸͺ‘ Changeset (Version Management) + +on: + push: + branches: + - develop + +jobs: + changeset_handler: + name: Changeset handler + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/create-github-app-token@v1 + id: fleek-platform-bot-token + with: + app-id: ${{ secrets.FLEEK_PLATFORM_BOT_APP_ID }} + private-key: ${{ secrets.FLEEK_PLATFORM_BOT_PRIVATE_KEY }} + + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.fleek-platform-bot-token.outputs.token }} + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + version: 7 + run_install: false + + - name: Setup Nodejs + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Changeset status + id: changeset-status + shell: bash + run: | + # Default skip state + skip=false + + if ! pnpm changeset:status &>/dev/null; then + echo "⚠️ Warning: No changesets found, should skip!" + skip=true + fi + + echo "skip=$skip" >> "$GITHUB_OUTPUT" + echo "Test 1" + if [[ ${{ steps.changeset-status.outputs.skip == 'true' ]]; then + echo "its quoted true" + fi + + if [[ ${{ steps.changeset-status.outputs.skip == 'false' ]]; then + echo "its quoted false" + fi + echo "Test 2" + if [[ ${{ steps.changeset-status.outputs.skip == true ]]; then + echo "its true" + fi + if [[ ${{ steps.changeset-status.outputs.skip == false ]]; then + echo "its false" + fi + + + - name: TIAS skip + run: | + echo "[debug] skip $skip" + + # - name: Get pnpm store directory + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # shell: bash + # run: | + # echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + # - uses: actions/cache@v4 + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # name: Setup pnpm cache + # with: + # path: ${{ env.STORE_PATH }} + # key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + # restore-keys: | + # ${{ runner.os }}-pnpm-store- + + # - name: Install dependencies + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # run: | + # pnpm install \ + # --strict-peer-dependencies + + # - name: Set version + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # run: | + # pnpm changeset:version + # git status --short + + # - name: Commit changes + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # run: | + # git config --global user.name "github-actions[bot]" + # git config --global user.email "github-actions[bot]@users.noreply.github.com" + + # if ! git add -A; then + # echo "πŸ‘Ή Oops! Failed stage changes" + # exit 1 + # fi + + # echo "βœ… Staged all changes!" + + # pkgVersion=$(node -p "require('./package.json').version") + # if ! git commit \ + # --allow-empty \ + # --no-verify \ + # -m "[skip ci] πŸ¦– updated package version to $pkgVersion"; then + # echo "πŸ‘Ή Oops! Failed to commit package version." + # exit 1 + # fi + + # echo "βœ… Committed package version!" + + # if ! git push; then + # echo "πŸ‘Ή Oops! Failed to push changes." + # exit 1 + # fi + + # echo "βœ… Pushed changes to repository!" diff --git a/.github/workflows/changeset-version-management.yml b/.github/workflows/changeset-version-management.yml index 47c8ce7..ca887c7 100644 --- a/.github/workflows/changeset-version-management.yml +++ b/.github/workflows/changeset-version-management.yml @@ -49,61 +49,81 @@ jobs: fi echo "skip=$skip" >> "$GITHUB_OUTPUT" - - - name: Get pnpm store directory - if: ${{ steps.changeset-status.outputs.skip != 'true' }} - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - if: ${{ steps.changeset-status.outputs.skip != 'true' }} - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - if: ${{ steps.changeset-status.outputs.skip != 'true' }} - run: | - pnpm install \ - --strict-peer-dependencies - - - name: Set version - if: ${{ steps.changeset-status.outputs.skip != 'true' }} - run: | - pnpm changeset:version - git status --short - - - name: Commit changes - if: ${{ steps.changeset-status.outputs.skip != 'true' }} - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" + echo "Test 1" + if [[ ${{ steps.changeset-status.outputs.skip == 'true' ]]; then + echo "its quoted true" + fi - if ! git add -A; then - echo "πŸ‘Ή Oops! Failed stage changes" - exit 1 + if [[ ${{ steps.changeset-status.outputs.skip == 'false' ]]; then + echo "its quoted false" fi - - echo "βœ… Staged all changes!" - - pkgVersion=$(node -p "require('./package.json').version") - if ! git commit \ - --allow-empty \ - --no-verify \ - -m "[skip ci] πŸ¦– updated package version to $pkgVersion"; then - echo "πŸ‘Ή Oops! Failed to commit package version." - exit 1 + echo "Test 2" + if [[ ${{ steps.changeset-status.outputs.skip == true ]]; then + echo "its true" fi - - echo "βœ… Committed package version!" - - if ! git push; then - echo "πŸ‘Ή Oops! Failed to push changes." - exit 1 + if [[ ${{ steps.changeset-status.outputs.skip == false ]]; then + echo "its false" fi - echo "βœ… Pushed changes to repository!" + + - name: TIAS skip + run: | + echo "[debug] skip $skip" + + # - name: Get pnpm store directory + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # shell: bash + # run: | + # echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + # - uses: actions/cache@v4 + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # name: Setup pnpm cache + # with: + # path: ${{ env.STORE_PATH }} + # key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + # restore-keys: | + # ${{ runner.os }}-pnpm-store- + + # - name: Install dependencies + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # run: | + # pnpm install \ + # --strict-peer-dependencies + + # - name: Set version + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # run: | + # pnpm changeset:version + # git status --short + + # - name: Commit changes + # if: ${{ steps.changeset-status.outputs.skip != 'true' }} + # run: | + # git config --global user.name "github-actions[bot]" + # git config --global user.email "github-actions[bot]@users.noreply.github.com" + + # if ! git add -A; then + # echo "πŸ‘Ή Oops! Failed stage changes" + # exit 1 + # fi + + # echo "βœ… Staged all changes!" + + # pkgVersion=$(node -p "require('./package.json').version") + # if ! git commit \ + # --allow-empty \ + # --no-verify \ + # -m "[skip ci] πŸ¦– updated package version to $pkgVersion"; then + # echo "πŸ‘Ή Oops! Failed to commit package version." + # exit 1 + # fi + + # echo "βœ… Committed package version!" + + # if ! git push; then + # echo "πŸ‘Ή Oops! Failed to push changes." + # exit 1 + # fi + + # echo "βœ… Pushed changes to repository!"