Skip to content

PyHC Environment Pipeline Workflow #510

PyHC Environment Pipeline Workflow

PyHC Environment Pipeline Workflow #510

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 }}