Skip to content

Commit

Permalink
ci: Add comment showing lastUpdated time for icons
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 22, 2024
1 parent 6c7e03b commit c98e8ee
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/fetch_icons/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions .github/fetch_icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/on-main.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -74,4 +75,4 @@
"url": "https://github.com/zebratechnologies/zeta-icons/issues"
},
"homepage": "https://github.com/zebratechnologies/zeta-icons#readme"
}
}

0 comments on commit c98e8ee

Please sign in to comment.