-
Notifications
You must be signed in to change notification settings - Fork 6
115 lines (99 loc) · 3.91 KB
/
catalog.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
104
105
106
107
108
109
110
111
112
113
114
115
name: Catalog
on:
pull_request:
branches:
workflow_dispatch:
repository_dispatch:
types:
- update-catalog
schedule:
- cron: "*/30 * * * *" # every 30 minutes. https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
permissions:
contents: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate-and-generate:
timeout-minutes: 30
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Echo originating repository
if: github.event_name == 'repository_dispatch'
run: |
echo "Originating repository: ${{ github.event.client_payload.origin_repo }}"
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Validate Feedstocks and Generate Catalog
uses: leap-stc/data-catalog-actions/leap-catalog@main
with:
generation-path: "catalog/input.yaml"
output-directory: "catalog/"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: consolidated-web-catalog.json
path: catalog/output/consolidated-web-catalog.json
update:
needs: validate-and-generate
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
environment:
name: ${{ github.event.pull_request.number }}
url: ${{ format('https://catalog-staging.leap.carbonplan.org/?catalog=https://raw.githubusercontent.com/{0}/{1}/catalog/output/consolidated-web-catalog.json', github.event.pull_request.head.repo.full_name, github.head_ref) }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Pull Remote Changes
run: |
git pull origin ${{ github.event.pull_request.head.ref }} --rebase --autostash
- uses: actions/download-artifact@v4
with:
name: consolidated-web-catalog.json
path: catalog/output
- name: Commit and Push
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
python -m pip install pre-commit
pre-commit install
git add catalog/output/consolidated-web-catalog.json
# run pre-commit and return 0 to avoid failing the job
pre-commit run || true
git add catalog/output/consolidated-web-catalog.json || true
git commit -m "Auto-update consolidated-web-catalog.json" || true
- name: Push changes
if: github.event_name == 'pull_request'
uses: ad-m/github-push-action@master
with:
# ssh: true
github_token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
branch: ${{ github.event.pull_request.head.ref }}
- name: Create Pull Request
id: cpr
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch') && github.ref == 'refs/heads/main'
uses: peter-evans/create-pull-request@v7
with:
commit-message: "build: update catalog"
committer: GitHub <[email protected]>
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
title: Update catalog
body: |
- Updates the consolidated web catalog for changes on `main`
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: update-consolidated-web-catalog
delete-branch: true