This repository has been archived by the owner on Dec 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
76 lines (76 loc) · 3.1 KB
/
UpdateContentOverview.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
name: Publish widget data
on:
push:
branches:
- master
paths:
- packages/**/*
- scripts/data/**/*
pull_request:
branches:
- master
paths:
- scripts/data/**/*
jobs:
publish-data:
runs-on: ubuntu-latest
steps:
- name: "Checking out code"
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2
with:
submodules: false
- name: "Setting up node"
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # v2
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: "Installing dependencies"
run: npm ci
- name: "Exporting data"
run: npm run content-overview:data
- name: Archive production artifacts
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2
with:
name: content.json
path: data/content.json
- name: "Set env variable"
run: echo "BASEPATH=/$GITHUB_REF_NAME" >> $GITHUB_ENV
- name: "Creating overview"
run: |
npm run content-overview:site:build
npm run content-overview:site:export
- name: "Creating pull request"
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
id: cpr
uses: peter-evans/create-pull-request@dcd5fd746d53dd8de555c0f10bca6c35628be47a # v3
with:
token: ${{ secrets.GH_PAT }}
branch: build/update-widgets-data
delete-branch: true
commit-message: "chore: update content data file"
title: "chore: Update content data file"
draft: false
add-paths: "data/content.json"
- name: "Enabling auto-merge for pull-request, if new"
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@d2ede5636b3febc92809259995e643565e675aab # v1
with:
token: ${{ secrets.GH_PAT }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: merge
- name: "Setting AWS credentials"
if: >-
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'push' && github.ref == 'refs/heads/master')
uses: aws-actions/configure-aws-credentials@05b148adc31e091bafbaf404f745055d4d3bc9d2 # v1.6.1
with:
aws-access-key-id: ${{ secrets.AWS_CONTENT_DATA_ID }}
aws-secret-access-key: ${{ secrets.AWS_CONTENT_DATA_SECRET }}
aws-region: eu-central-1
- name: "Copy data to out folder"
run: cp data/content.json scripts/data/out/content.json
- name: "Uploading to S3"
if: >-
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'push' && github.ref == 'refs/heads/master')
run: |
aws s3 sync scripts/data/out s3://widgetresources-data/$GITHUB_REF_NAME/
echo https://widgetresources-data.s3.eu-central-1.amazonaws.com/$GITHUB_REF_NAME/index.html