createGeoJson #74242
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: createGeoJson | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
schedule: | |
- cron: '*/15 * * * *' | |
jobs: | |
createGeoJson-job: | |
runs-on: ubuntu-latest | |
steps: | |
# prepare and save the files in git | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: produce geojson | |
id: produce-geojson | |
shell: pwsh | |
run: ./createGeoJson.ps1 | |
working-directory: ./.github/workflows | |
- name: prep repo and commit | |
if: always() | |
run: | | |
git config --global user.name 'atlantis-green' | |
git config --global user.email 'atlantis-green@users.noreply.github.com' | |
git add . | |
git commit -m "Update the data" | |
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
git fetch | |
- name: commit files to data branch | |
run: git switch data | |
- name: commit files to the error branch if produce-geojson failed | |
if: ${{ steps.produce-geojson.conclusion == 'failure'}} | |
run: git switch error | |
- name: finish committing the stuff | |
if: always() | |
run: | | |
cd ./data | |
rm * -r | |
git cherry-pick ${{ env.COMMIT_HASH }} --strategy-option=theirs | |
git push -u origin HEAD | |
git checkout ${{ env.COMMIT_HASH }} | |
# commented out -- more details in #11 -- https://github.com/marknooch/foodtrucks/issues/11 | |
# - name: download the geojson schema | |
# run: curl https://geojson.org/schema/GeoJSON.json --output ./GeoJSON.json | |
# - name: confirm we produced valid GeoJSON | |
# uses: nhalstead/validate-json-action@0.1.3 | |
# with: | |
# schema: ./GeoJSON.json | |
# jsons: /data/openFoodTrucks.json | |
# now we move the files to s3 | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: deploy data to s3 | |
run: | | |
aws s3 sync ./data s3://${{ secrets.S3_BUCKET }} --expires "$(date -d '+15 minutes' --utc +'%Y-%m-%dT%H:%M:%SZ')" | |
aws s3 sync ./src s3://${{ secrets.S3_BUCKET }} | |
- name: invalidate cache on every completed pull request | |
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} | |
run: | | |
aws cloudfront list-distributions | \ | |
jq -r '.DistributionList.Items[].Id' | \ | |
while read id ; do aws cloudfront create-invalidation --distribution-id $id --paths "/*" ; done | |