forked from PyPSA/pypsa-eur
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (74 loc) · 2.74 KB
/
update-pinned-env.yaml
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
name: Update pinned envs
on:
push:
paths:
- envs/environment.yaml
schedule:
- cron: "0 8 1,16 * *" # Bi-weekly
workflow_dispatch:
env:
BASE_ENV: envs/environment.yaml
jobs:
update-pinned-environment:
if: ${{ github.ref == 'refs/heads/master' }}
name: Update pinned envs
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
include:
- os: ubuntu
suffix: "linux"
- os: macos
suffix: "macos"
- os: windows
suffix: "windows"
steps:
- uses: actions/checkout@v4
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: ${{ github.event.repository.name }}
environment-file: envs/environment.yaml
- name: Update pinned environment per OS
run: |
conda env export --name ${{ github.event.repository.name }} --no-builds > envs/${{ matrix.suffix }}-pinned.yaml
- name: Add SPDX header
if: ${{ matrix.suffix != 'windows' }}
run: |
SPDX_HEADER="# SPDX-FileCopyrightText: 2017-2024 The PyPSA-Eur Authors\n# SPDX-License-Identifier: CC0-1.0\n"
echo -e "$SPDX_HEADER" | cat - envs/${{ matrix.suffix }}-pinned.yaml > temp && mv temp envs/${{ matrix.suffix }}-pinned.yaml
- name: Add SPDX header (windows)
if: ${{ matrix.suffix == 'windows' }}
run: |
$SPDX_HEADER = "# SPDX-FileCopyrightText: 2017-2024 The PyPSA-Eur Authors`r`n# SPDX-License-Identifier: CC0-1.0`r`n`r`n"
$CurrentContent = Get-Content "envs/${{ matrix.suffix }}-pinned.yaml" -Raw
$NewContent = $SPDX_HEADER + $CurrentContent
$NewContent | Set-Content "envs/${{ matrix.suffix }}-pinned.yaml"
- name: Cache environment files
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.suffix }}-pinned
path: envs/${{ matrix.suffix }}-pinned.yaml
create-pull-request:
needs: update-pinned-environment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Prepare files for commit
run: |
mkdir -p envs
mv linux-pinned/* envs/linux-pinned.yaml
mv macos-pinned/* envs/macos-pinned.yaml
mv windows-pinned/* envs/windows-pinned.yaml
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-pinned-environment
title: "[github-actions.ci] Update pinned envs"
body: "Automatically generated PR to update pinned environment files for Windows, macOS, and Linux."
commit-message: "Update pinned environment files for all platforms"