From c98e8ee700fae1d553e44aab41fa349cf7384671 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 22 Oct 2024 15:51:18 +0100 Subject: [PATCH 1/5] ci: Add comment showing lastUpdated time for icons --- .github/fetch_icons/action.yml | 3 +++ .github/fetch_icons/index.js | 4 ++++ .github/workflows/build.yml | 8 ++++---- .github/workflows/on-main.yml | 20 ++++++++++++++++++++ .github/workflows/on-pr.yml | 11 +++++++++++ package.json | 3 ++- 6 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/on-main.yml diff --git a/.github/fetch_icons/action.yml b/.github/fetch_icons/action.yml index 1e4788f0..feff5b20 100644 --- a/.github/fetch_icons/action.yml +++ b/.github/fetch_icons/action.yml @@ -4,6 +4,9 @@ inputs: figma-access-token: description: "The personal access token given by Figma. Required to make API calls" required: true + date: + description: "The date and time the action was run" + required: true outputs: files_changed: description: "Boolean that gets set to true if any icons have been added or removed" diff --git a/.github/fetch_icons/index.js b/.github/fetch_icons/index.js index 1906ec90..961b8630 100644 --- a/.github/fetch_icons/index.js +++ b/.github/fetch_icons/index.js @@ -4,6 +4,7 @@ import fetchIcons from "../../dist/scripts/fetch-icons/fetchIcons.js"; import { ZDS_ASSETS_FILE_ID, ZDS_ASSETS_ICON_PAGE_NAME } from "../../figmaConfig.js"; const FIGMA_ACCESS_TOKEN = core.getInput("figma-access-token") || process.env.FIGMA_ACCESS_TOKEN; +const DATE = core.getInput("date") || 'now'; try { const hashPath = "./.github/fetch_icons/hash.txt"; @@ -26,6 +27,9 @@ try { if (newHash) { writeFileSync(hashPath, newHash); + const packageJson = JSON.parse(readFileSync("./package.json").toString()); + packageJson.lastUpdated = DATE; + writeFileSync("./package.json", JSON.stringify(packageJson, null, 2)); } console.log("Files changed", newHash); core.setOutput("files_changed", newHash != undefined); diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3613315a..fc3799bf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,20 +39,20 @@ jobs: if: ${{github.event_name != 'schedule'}} run: | : > ./.github/fetch_icons/hash.txt + - name: Get date / time + id: date + run: echo date=$(date +'%d %b %Y, %H:%M:%S') >> $GITHUB_OUTPUT - name: Fetch icons id: "fetch_icons" uses: ./.github/fetch_icons with: figma-access-token: ${{ secrets.FIGMA_PERSONAL_ACCESS_TOKEN }} + date: ${{ steps.date.outputs.date }} - name: Icons changed run: echo ${{ steps.fetch_icons.outputs.files_changed }} - name: Create code connect files if: ${{ steps.fetch_icons.outputs.files_changed == 'true'}} uses: ./.github/create_code_connect - - name: Get current date - if: ${{ steps.fetch_icons.outputs.files_changed == 'true'}} - id: date - run: echo date=$(date +'%d-%b-%Y') >> $GITHUB_OUTPUT - name: Create PR title id: title run: | diff --git a/.github/workflows/on-main.yml b/.github/workflows/on-main.yml new file mode 100644 index 00000000..cd64dd5b --- /dev/null +++ b/.github/workflows/on-main.yml @@ -0,0 +1,20 @@ +name: CI - On Main + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@v4 + with: + token: ${{ secrets.PAT }} + config-file: release-please-config.json + manifest-file: .release-please-manifest.json diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index 96a5ab2b..aa64dc83 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -22,3 +22,14 @@ jobs: run: npm ci - name: Run tests run: npm run test + - name: Get lastUpdated from package.json + id: lastUpdated + run: echo "lastUpdated=$(cat package.json | jq .lastUpdated)" >> $GITHUB_OUTPUT + - name: Comment + uses: mikedloss/create-update-comment@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + unique-identifier: "lastUpdated comment" + message: | + ## PR is ready to merge. + Last updated: ${{steps.lastUpdated.outputs.lastUpdated}} diff --git a/package.json b/package.json index b3f04073..80cf7baf 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "@zebra-fed/zeta-icons", "version": "0.8.1", "type": "module", + "lastUpdated": "18 Oct 2024, 15:25:00", "main": "index.js", "types": "dist/index.d.ts", "files": [ @@ -74,4 +75,4 @@ "url": "https://github.com/zebratechnologies/zeta-icons/issues" }, "homepage": "https://github.com/zebratechnologies/zeta-icons#readme" -} +} \ No newline at end of file From b5215c2d4e1bafa28e1eb7512b6df1687221b29e Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 23 Oct 2024 10:25:56 +0100 Subject: [PATCH 2/5] test --- .github/workflows/on-pr.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index aa64dc83..c5096186 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -2,6 +2,11 @@ name: CI - Pull Request on: pull_request +# Pull Request Runs on the same branch will be cancelled +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + env: FIGMA_ACCESS_TOKEN: ${{secrets.FIGMA_PERSONAL_ACCESS_TOKEN}} @@ -22,14 +27,21 @@ jobs: run: npm ci - name: Run tests run: npm run test - - name: Get lastUpdated from package.json - id: lastUpdated - run: echo "lastUpdated=$(cat package.json | jq .lastUpdated)" >> $GITHUB_OUTPUT + + release-comment: + name: Release Comment + runs-on: ubuntu-latest + if: ${{ contains(github.event.pull_request.title, 'release zeta-icons') }} && ${{ contains(github.event.pull_request.title, 'chore(main)') }} + steps: + - name: Get lastUpdated + if: lastUpdated + run: echo "lastUpdated=${{cat package.json | jq .lastUpdated}}" >> $GITHUB_ENV + - name: Comment uses: mikedloss/create-update-comment@v1 with: token: ${{ secrets.GITHUB_TOKEN }} unique-identifier: "lastUpdated comment" message: | - ## PR is ready to merge. - Last updated: ${{steps.lastUpdated.outputs.lastUpdated}} + ### PR is ready to merge. + Last updated: ${{ steps.lastUpdated.outputs.lastUpdated }} From b1ac32498a90b9e950170929f3fb0788dc57fac7 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 23 Oct 2024 10:38:17 +0100 Subject: [PATCH 3/5] test --- .github/workflows/on-pr.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index c5096186..5910330f 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -35,8 +35,7 @@ jobs: steps: - name: Get lastUpdated if: lastUpdated - run: echo "lastUpdated=${{cat package.json | jq .lastUpdated}}" >> $GITHUB_ENV - + run: echo "lastUpdated=$(cat package.json | jq .lastUpdated)" >> $GITHUB_ENV - name: Comment uses: mikedloss/create-update-comment@v1 with: From 9678d3f1ce7dae5144c26dc0bd386f8ef343c553 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 23 Oct 2024 10:39:02 +0100 Subject: [PATCH 4/5] test --- .github/workflows/on-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index 5910330f..d11f7df1 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Get lastUpdated if: lastUpdated - run: echo "lastUpdated=$(cat package.json | jq .lastUpdated)" >> $GITHUB_ENV + run: echo "lastUpdated=$(cat package.json | jq .lastUpdated)" >> $GITHUB_OUTPUT - name: Comment uses: mikedloss/create-update-comment@v1 with: From 916dec509ad6e2a1bec339a868fe8e314c59d618 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 23 Oct 2024 10:39:28 +0100 Subject: [PATCH 5/5] test --- .github/workflows/on-pr.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index d11f7df1..d67002f4 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -31,10 +31,12 @@ jobs: release-comment: name: Release Comment runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.title, 'release zeta-icons') }} && ${{ contains(github.event.pull_request.title, 'chore(main)') }} + if: ${{ contains(github.event.pull_request.title, 'release zeta-icons')}} steps: + - name: Checkout + uses: actions/checkout@v4 - name: Get lastUpdated - if: lastUpdated + id: lastUpdated run: echo "lastUpdated=$(cat package.json | jq .lastUpdated)" >> $GITHUB_OUTPUT - name: Comment uses: mikedloss/create-update-comment@v1