Write data to Pages #58560
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: Write data to Pages | |
on: | |
workflow_run: | |
workflows: [Get WX data, Get station data] | |
types: [completed] | |
jobs: | |
debug-github-context: | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo '${{ toJSON(github) }}' | jq . | |
add-weather-data-to-pages: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: download artifacts and copy to Pages data folder | |
run: | | |
gh run download ${{ github.event.workflow_run.id }} -n weather-data -n station-data | |
if [ -d "weather-data" ]; then | |
cp weather-data/* _data/metars | |
echo '::info::Copied weather data to _data/metars' | |
fi | |
if [ -d "station-data" ]; then | |
cp station-data/* _data/stations | |
echo '::info::Copied station data to _data/stations' | |
fi | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: set new timestamp for when data was last updated (TODO REMOVE) | |
run: | | |
UPDATE_TIME=$(date -u '+%a, %b %d, %Y - %r GMT') yq -i '.update_time = strenv(UPDATE_TIME)' _data/weather.yml | |
- name: commit changes to branch | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
if git diff --quiet; then | |
echo "no changes; nothing to commit" | |
else | |
git add _data/* | |
git commit -m 'update site with current wx data' | |
git push | |
fi | |
job-ran-if-not-success: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion != 'success' }} | |
steps: | |
- run: | | |
echo 'Check out DEBUG step; ...conclusion != '"'success'" |