Update Dockerfile from Source #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Dockerfile from Source | |
# For this to work, you must all actions to create PRs at the org level | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
paths: | |
- '.github/workflows/update-pangeo-dockerfile.yml' | |
workflow_dispatch: # Manual trigger | |
schedule: | |
- cron: '0 3 * * *' # Runs daily at 3:00 AM UTC | |
jobs: | |
update-dockerfile: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} # Base branch (main or dev) | |
- name: Fetch Raw Dockerfile | |
id: fetch_dockerfile | |
run: | | |
URL="https://raw.githubusercontent.com/pangeo-data/pangeo-docker-images/master/base-image/Dockerfile" | |
curl -o base-image/Dockerfile.temp $URL | |
# Strip everything after ENTRYPOINT and save it to a new file | |
awk '/ENTRYPOINT/ {print; exit} {print}' base-image/Dockerfile.temp > base-image/Dockerfile.new | |
rm base-image/Dockerfile.temp | |
# Compare the downloaded version with the existing Dockerfile | |
if cmp -s base-image/Dockerfile base-image/Dockerfile.new; then | |
echo "No changes in Dockerfile." | |
echo "changed=false" >> $GITHUB_ENV | |
rm base-image/Dockerfile.new | |
else | |
echo "Dockerfile has changed." | |
mv base-image/Dockerfile.new base-image/Dockerfile | |
echo "changed=true" >> $GITHUB_ENV | |
fi | |
- name: Create Pull Request | |
if: env.changed == 'true' | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
commit-message: Update base-image Dockerfile | |
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
branch: update-dockerfile | |
delete-branch: true | |
title: 'Update Dockerfile' | |
body: | | |
Update Pangeo base-image Dockerfile | |
- Auto-generated by [create-pull-request][1] | |
[1]: https://github.com/peter-evans/create-pull-request | |
assignees: eeholmes | |
reviewers: eeholmes | |
draft: false | |