Skip to content

Commit 23649ad

Browse files
authored
Update update-pinned-env.yaml
1 parent 14dc820 commit 23649ad

File tree

2 files changed

+87
-39
lines changed

2 files changed

+87
-39
lines changed

.github/workflows/update-fixed-env.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Update pinned envs
2+
3+
on:
4+
push:
5+
paths:
6+
- envs/environment.yaml
7+
schedule:
8+
- cron: "0 8 1,16 * *" # Bi-weekly
9+
workflow_dispatch:
10+
11+
env:
12+
BASE_ENV: envs/environment.yaml
13+
14+
jobs:
15+
update-pinned-environment:
16+
if: ${{ github.ref == 'refs/heads/main' }}
17+
name: Update pinned envs
18+
runs-on: ${{ matrix.os }}-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu, macos, windows]
23+
include:
24+
- os: ubuntu
25+
suffix: "linux"
26+
- os: macos
27+
suffix: "macos"
28+
- os: windows
29+
suffix: "windows"
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Setup conda
35+
uses: conda-incubator/setup-miniconda@v3
36+
with:
37+
activate-environment: ${{ github.event.repository.name }}
38+
channels: bioconda,conda-forge,defaults
39+
environment-file: ${{ env.BASE_ENV }}
40+
41+
- name: Update pinned environment per OS
42+
run: |
43+
conda env export --name ${{ github.event.repository.name }} --no-builds -c conda-forge -c bioconda --override-channels > envs/${{ matrix.suffix }}-pinned.yaml
44+
45+
# - name: Add SPDX header
46+
# if: ${{ matrix.suffix != 'windows' }}
47+
# run: |
48+
# SPDX_HEADER="# SPDX-FileCopyrightText: Contributors to PyPSA-Eur <https://github.com/pypsa/pypsa-eur>\n# SPDX-License-Identifier: CC0-1.0\n"
49+
# echo -e "$SPDX_HEADER" | cat - envs/${{ matrix.suffix }}-pinned.yaml > temp && mv temp envs/${{ matrix.suffix }}-pinned.yaml
50+
51+
# - name: Add SPDX header (windows)
52+
# if: ${{ matrix.suffix == 'windows' }}
53+
# run: |
54+
# $SPDX_HEADER = "# SPDX-FileCopyrightText: Contributors to PyPSA-Eur <https://github.com/pypsa/pypsa-eur>`r`n# SPDX-License-Identifier: CC0-1.0`r`n`r`n"
55+
# $CurrentContent = Get-Content "envs/${{ matrix.suffix }}-pinned.yaml" -Raw
56+
# $NewContent = $SPDX_HEADER + $CurrentContent
57+
# $NewContent | Set-Content "envs/${{ matrix.suffix }}-pinned.yaml"
58+
59+
- name: Cache environment files
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: ${{ matrix.suffix }}-pinned
63+
path: envs/${{ matrix.suffix }}-pinned.yaml
64+
65+
create-pull-request:
66+
needs: update-pinned-environment
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v4
70+
- name: Download all artifacts
71+
uses: actions/download-artifact@v4
72+
73+
- name: Prepare files for commit
74+
run: |
75+
mkdir -p envs
76+
mv linux-pinned/* envs/linux-pinned.yaml
77+
mv macos-pinned/* envs/macos-pinned.yaml
78+
mv windows-pinned/* envs/windows-pinned.yaml
79+
80+
- name: Create Pull Request
81+
uses: peter-evans/create-pull-request@v7
82+
with:
83+
token: ${{ secrets.GITHUB_TOKEN }}
84+
branch: update-pinned-environment
85+
title: "[github-actions.ci] Update pinned envs"
86+
body: "Automatically generated PR to update pinned environment files for Windows, macOS, and Linux."
87+
commit-message: "Update pinned environment files for all platforms"

0 commit comments

Comments
 (0)