-
-
Notifications
You must be signed in to change notification settings - Fork 118
93 lines (81 loc) · 3.04 KB
/
zenodo-cache-sync.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
---
name: zenodo-cache-sync
on:
workflow_dispatch:
schedule:
- cron: "0 6 * * 1-5" # Weekdays at midnight on MST
pull_request:
paths:
- "src/pudl/workspace/datastore.py"
env:
INTERNAL_ZENODO_CACHE_BUCKET: gs://internal-zenodo-cache.catalyst.coop
PUBLIC_ZENODO_CACHE_BUCKET: gs://zenodo-cache.catalyst.coop
PUDL_OUTPUT: ~/pudl-work/output
PUDL_INPUT: ~/pudl-work/input/
jobs:
zenodo-cache-sync:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout desired branch
uses: actions/checkout@v4
- name: Install Conda environment using mamba
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environments/conda-lock.yml
environment-name: pudl-dev
cache-environment: true
- name: Log environment details
run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- name: Install pudl package
run: |
pip install --editable ./
- name: Set default gcp credentials
id: gcloud-auth
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: "projects/345950277072/locations/global/workloadIdentityPools/gh-actions-pool/providers/gh-actions-provider"
service_account: "zenodo-cache-manager@catalyst-cooperative-pudl.iam.gserviceaccount.com"
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Update GCS cache with any new Zenodo archives
run: |
pudl_datastore --gcs-cache-path ${{ env.INTERNAL_ZENODO_CACHE_BUCKET }} --bypass-local-cache --loglevel DEBUG
- name: Sync internal and public caches
run: |
gcloud storage --billing-project=catalyst-cooperative-pudl rsync -r ${{ env.INTERNAL_ZENODO_CACHE_BUCKET }} ${{ env.PUBLIC_ZENODO_CACHE_BUCKET }}
zenodo-cache-sync-notify:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: zenodo-cache-sync
steps:
- name: Inform the Codemonkeys
uses: 8398a7/action-slack@v3
with:
status: custom
fields: workflow,job,commit,repo,ref,author,took
custom_payload: |
{
username: 'action-slack',
icon_emoji: ':octocat:',
attachments: [{
color: '${{ needs.zenodo-cache-sync.result }}' === 'success' ? 'good' : '${{ needs.zenodo-cache-sync.result }}' === 'failure' ? 'danger' : 'warning',
text: `${process.env.AS_REPO}@${process.env.AS_REF}\n ${process.env.AS_WORKFLOW} (${process.env.AS_COMMIT})\n by ${process.env.AS_AUTHOR}\n Status: ${{ needs.zenodo-cache-sync.result }}`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
MATRIX_CONTEXT: ${{ toJson(matrix) }} # required