Skip to content

Unit+area charts

Unit+area charts #585

name: Preview catalog
on:
pull_request_target:
branches:
- main
types:
- opened
- reopened
- synchronize
- closed
workflow_dispatch:
# do not allow running multiple of pipelines for this PR in parallel
concurrency: preview-${{ github.ref }}
jobs:
preview_changed_files:
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
pull-requests: write
packages: read
name: Deploy changed-files
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Get commit message from PR head branch
id: get_pr_commit_message
run: |
PR_COMMIT_SHA=${{ github.event.pull_request.head.sha }}
PR_REPO_OWNER=${{ github.event.pull_request.head.repo.owner.login }}
PR_REPO_NAME=${{ github.event.pull_request.head.repo.name }}
# Fetch the commit message from the PR's head branch
COMMIT_MESSAGE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${PR_REPO_OWNER}/${PR_REPO_NAME}/commits/${PR_COMMIT_SHA}" \
| jq -r .commit.message)
# Setting skip flag.
if [[ "$COMMIT_MESSAGE" == *"create session using empty commit"* ]]; then
echo "should_skip=true" >> "$GITHUB_OUTPUT"
else
echo "should_skip=false" >> "$GITHUB_OUTPUT"
fi
-
if: github.event.action != 'closed' # skip the step if the PR has been closed, just for cleanup
name: changed-files
id: changed-files
uses: tj-actions/changed-files@v45
# To compare changes between the current commit and the last pushed remote commit set `since_last_remote_commit: true`. e.g
# with:
# since_last_remote_commit: true
-
if: github.event.action != 'closed' # skip the step if the PR has been closed, just for cleanup
name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: python .github/update_catalog.py
-
if: github.event.action != 'closed' && steps.get_pr_commit_message.outputs.should_skip != 'true'
name: Build
env:
SH_INSTANCE_ID: ${{ secrets.SH_INSTANCE_ID }}
SH_CLIENT_ID: ${{ secrets.SH_CLIENT_ID }}
SH_CLIENT_SECRET: ${{ secrets.SH_CLIENT_SECRET }}
run: |
docker run -v "$PWD:/workspace" -w "/workspace" -e SH_INSTANCE_ID="$SH_INSTANCE_ID" -e SH_CLIENT_ID="$SH_CLIENT_ID" -e SH_CLIENT_SECRET="$SH_CLIENT_SECRET" ghcr.io/eodash/eodash_catalog:0.4.4 eodash_catalog -gp
- if: steps.get_pr_commit_message.outputs.should_skip != 'true'
name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./build/
comment: false
-
if: github.event.action != 'closed' && steps.get_pr_commit_message.outputs.should_skip != 'true'
name: Find existing comment
id: find-comment
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: github-actions
body-includes: '🚀 Preview ready!'
-
if: github.event.action != 'closed' && steps.get_pr_commit_message.outputs.should_skip != 'true'
name: Create or update preview comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
🚀 Preview ready!
👉 [View your dashboard preview](https://eodash.github.io/preview-instance/?stacEndpoint=https://esa-eodashboards.github.io/eodashboard-catalog/pr-preview/pr-${{ github.event.pull_request.number }}/trilateral/catalog.json )
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
-
if: github.event.action != 'closed' && steps.get_pr_commit_message.outputs.should_skip != 'true'
name: Wait for GitHub Pages deployment workflow
run: |
echo "Waiting for GitHub Pages deployment to complete..."
ATTEMPTS=0
MAX_ATTEMPTS=30
DELAY=10
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
RUN=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/actions/runs \
| jq '.workflow_runs[] | select(.name=="pages build and deployment")' \
| jq -s 'sort_by(.run_started_at) | reverse | .[0]')
STATUS=$(echo "$RUN" | jq -r '.status')
CONCLUSION=$(echo "$RUN" | jq -r '.conclusion')
echo "Current pages-build-deployment status: $STATUS / $CONCLUSION"
if [[ "$STATUS" == "completed" ]]; then
if [[ "$CONCLUSION" == "success" ]]; then
echo "✅ GitHub Pages deployment completed successfully."
exit 0
else
echo "❌ GitHub Pages deployment failed."
exit 1
fi
fi
ATTEMPTS=$((ATTEMPTS+1))
sleep $DELAY
done
echo "⚠️ Timed out waiting for GitHub Pages deployment."
exit 1