-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (91 loc) · 3.91 KB
/
pyhc_env_pipeline_workflow.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
name: PyHC Environment Pipeline Workflow
on:
schedule:
- cron: '0 7 * * *' # Runs at midnight Mountain Time (UTC-7)
workflow_dispatch:
jobs:
run-pipeline:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Fetch LFS Files
run: git lfs pull
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install Pipeline Dependencies
run: |
pip install -r pipeline_requirements.txt
- name: Run Pipeline Script
id: pipeline_check
run: python pipeline.py
- name: Update README Table
if: steps.pipeline_check.outputs.should_run == 'true'
run: python utils/update_readme.py
- name: Build and Push Docker Images
if: steps.pipeline_check.outputs.should_run == 'true'
id: build_and_push # Assigning an ID to reference outputs
run: python utils/docker_operations.py ./docker ${{ secrets.DOCKER_HUB_USERNAME }} ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Commit and Push Repo Changes (No Conflicts)
if: steps.pipeline_check.outputs.should_run == 'true' && steps.pipeline_check.outputs.has_conflict != 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Update Docker image requirements, spreadsheet, README" || exit 0
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update science-platforms-coordination to Trigger Binder Rebuild
if: steps.pipeline_check.outputs.should_run == 'true' && steps.pipeline_check.outputs.has_conflict != 'true'
run: |
# Clone the target repo using a PAT with push permissions
git clone https://${{ secrets.SCIENCE_PLATFORMS_PAT }}@github.com/heliophysicsPy/science-platforms-coordination.git coordination_repo
cd coordination_repo
git checkout pyhc
# Use sed to update the 'FROM' line in the Dockerfile with the new version
sed -i "s|^FROM spolson/pyhc-environment:.*|FROM spolson/pyhc-environment:${{ steps.build_and_push.outputs.docker_version }}|" Dockerfile
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add Dockerfile
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit."
else
git commit -m "Update base image version to ${{ steps.build_and_push.outputs.docker_version }}"
git push origin pyhc
fi
- name: Commit and Push Conflicted Spreadsheet
if: steps.pipeline_check.outputs.has_conflict == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Only add the conflict spreadsheet(s):
git add spreadsheets/*.xlsx
git commit -m "Add dependency conflict spreadsheet" || exit 0
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify on Successful Push
if: steps.pipeline_check.outputs.should_run == 'true'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: 2
body: |
Docker Hub images and GitHub repo have been updated by GitHub Actions.
Updated:
```
${{ steps.pipeline_check.outputs.package_updates }}
```
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify on Dependency Conflict
if: steps.pipeline_check.outputs.has_conflict == 'true'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: 2
body: |
A dependency conflict was found. The conflict spreadsheet has been pushed to the repo.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}