-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (95 loc) · 3.56 KB
/
tokens-diff.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Check for token changes
on:
pull_request:
types: [opened, edited]
defaults:
run:
working-directory: packages/tokens
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
jobs:
compare-tokens:
if: contains(github.event.pull_request.head.ref, 'dependabot/npm_and_yarn/packages/tokens/department-of-veterans-affairs/css-library')
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
token: ${{ secrets.VA_MOBILE_ROBOT_GITHUB_PAT }}
- name: Set git credentials and regenerate yarn.lock
run: |
git config --global user.name 'VA Automation Bot'
git config --global user.email '[email protected]'
yarn install
if git status --porcelain | grep -q '^[ MARC].*yarn.lock'; then
echo "yarn.lock has unstaged changes."
cd ../..
git add yarn.lock
git commit -m 'Regenerate yarn.lock'
git push
fi
- name: Build and compare tokens
run: |
echo NEW_VERSION=$(jq -r '.devDependencies["@department-of-veterans-affairs/css-library"]' package.json) >> $GITHUB_ENV
yarn tokens:build
cd dist/js
cp colors.js colors_new.js
git checkout main
echo PREV_VERSION=$(jq -r '.devDependencies["@department-of-veterans-affairs/css-library"]' ../../package.json) >> $GITHUB_ENV
yarn && yarn tokens:build
if diff -q colors.js colors_new.js > /dev/null; then
echo "Files have the same contents."
echo "TOKENS_CHANGED=false" >> $GITHUB_ENV
else
echo "Files have different contents."
echo "TOKENS_CHANGED=true" >> $GITHUB_ENV
fi
- name: Send slack message
id: slack
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_OAUTH_TOKEN }}
with:
channel-id: C062TM03HN2 # DSVA #va-mobile-library-alerts channel
payload: |
{
"text": "Dependabot found an update to *@department-of-veterans-affairs/css-library*",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*TEST* Dependabot found an update to *@department-of-veterans-affairs/css-library*"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "*Previous version:* ${{ env.PREV_VERSION }}"
},
{
"type": "mrkdwn",
"text": "*New version:* ${{ env.NEW_VERSION }}"
},
{
"type": "mrkdwn",
"text": "<https://github.com/department-of-veterans-affairs/component-library/releases|Changelog>"
},
{
"type": "mrkdwn",
"text": "<${{ github.event.pull_request.html_url }}|Pull Request>"
},
{
"type": "mrkdwn",
"text": "*Tokens changed:* ${{ env.TOKENS_CHANGED }}"
}
]
}
],
"unfurl_links": false,
"unfurl_media": false
}