-
Notifications
You must be signed in to change notification settings - Fork 49
Actions workflow to sync icons to the bucket #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ffad40e
d463961
7aeb37a
def0a0a
8ff11b2
2654e62
2173e1c
b8863ca
e8c8ae3
4bd8583
583fdea
a60de20
35d24e9
0d4e2aa
80117b4
0ab2b75
2f974f1
a6d861b
07b9688
14e3281
ed53ed2
ce77f5f
cc23a7b
c0e8dab
bf378ee
86c4cbe
d1e6dc7
a83dd9d
9d94832
b6ac801
489fc8c
45b63e1
cd7df4e
011a4c6
5448ad6
961fbb7
0b3e6c9
9e94eec
e91a537
e386141
2ebecef
defe23a
5961532
ef68932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,91 @@ | ||
| name: Tests | ||
| name: Upload technologies to BQ and Cloud Storage | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - ".github/workflows/upload.yml" | ||
| - "src/technologies/*.json" | ||
| - "src/categories.json" | ||
| - "src/groups.json" | ||
| - "src/images/icons/**" | ||
| workflow_dispatch: | ||
| inputs: | ||
| force_update: | ||
| description: 'Force update regardless of changes' | ||
| required: false | ||
| default: 'false' | ||
max-ostapenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| jobs: | ||
| test: | ||
| name: Test and upload to GCP | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install | ||
|
|
||
| - name: Validate | ||
| run: yarn run validate | ||
|
|
||
| - name: Run WebPageTest with unit tests | ||
| id: unit-test | ||
| env: | ||
| WPT_SERVER: "webpagetest.httparchive.org" | ||
| WPT_API_KEY: ${{ secrets.HA_API_KEY }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| run: yarn run test | ||
| - name: Get changed technology files | ||
| run: | | ||
| git log -1 HEAD^ | ||
| git log -1 HEAD | ||
|
|
||
| git fetch origin main --depth=1 | ||
| TECH_FILES_CHANGED=$(git diff --name-only HEAD^ HEAD -- 'src/technologies/*.json' 'src/categories.json' 'src/groups.json' | wc -l) | ||
| echo $TECH_FILES_CHANGED | ||
| echo "TECH_FILES_CHANGED=${TECH_FILES_CHANGED}" >> $GITHUB_ENV | ||
|
|
||
| - name: Upload to GCP | ||
| id: upload | ||
| - name: Upload technology rules to BigQuery | ||
| if: env.TECH_FILES_CHANGED != '' || inputs.force_update == 'true' | ||
| env: | ||
| GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | ||
| GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} | ||
| run: yarn run tech_upload | ||
|
|
||
| - name: Get changed icons | ||
| run: | | ||
| git fetch origin main --depth=1 | ||
|
|
||
| if [[ "${{ inputs.force_update }}" == "true" ]]; then | ||
| CHANGED_ICONS=$(find src/images/icons -name "*.svg" -o -name "*.png" | xargs) | ||
| else | ||
| CHANGED_ICONS=$(git diff --name-only HEAD^ HEAD -- 'src/images/icons/*.svg' 'src/images/icons/*.png' | xargs) | ||
| fi | ||
|
|
||
| echo $CHANGED_ICONS | ||
| echo "CHANGED_ICONS=${CHANGED_ICONS}" >> $GITHUB_ENV | ||
|
|
||
| # PNG are generally smaller, and we have some SVG that are 1Mb, so conversion to PNG is necessary. | ||
| - name: Install Image Conversion Package | ||
| if: env.CHANGED_ICONS != '' | ||
| run: sudo apt-get install -y librsvg2-bin | ||
|
|
||
| - name: Convert changed SVGs to PNGs | ||
| if: env.CHANGED_ICONS != '' | ||
| run: | | ||
| for file in $CHANGED_ICONS; do | ||
| if [[ "$file" == *.svg ]]; then | ||
| rsvg-convert "$file" -o "${file%.svg}.png" -w 16 -h 16 | ||
| fi | ||
| done | ||
|
Comment on lines
+71
to
+78
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't we use SVGs if in that format already? Maybe add a comment to explain?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PNG are generally smaller, and we have some SVG that are 1Mb. |
||
|
|
||
| - uses: 'google-github-actions/auth@v2' | ||
| if: env.CHANGED_ICONS != '' || inputs.force_update == 'true' | ||
| with: | ||
| credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
|
|
||
| - uses: 'google-github-actions/setup-gcloud@v2' | ||
| if: env.CHANGED_ICONS != '' || inputs.force_update == 'true' | ||
|
|
||
| - name: Sync new PNGs to Cloud Storage | ||
| if: env.CHANGED_ICONS != '' || inputs.force_update == 'true' | ||
| run: | | ||
| echo $GCP_SA_KEY > /tmp/gcp_key.json | ||
| yarn run upload | ||
| gcloud storage rsync src/images/icons/ gs://httparchive/static/icons/ --exclude=".*.svg$" --cache-control="public, max-age=31536000, immutable" | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,3 +208,5 @@ fs.readdirSync(iconPath).forEach((file) => { | |
| } | ||
| } | ||
| }) | ||
|
|
||
| console.log('Validation completed successfully.') | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we exclude these?
Most of our contributions are to these files and I'd like to lint them.