diff --git a/.github/workflows/build_main.yaml b/.github/workflows/build_main.yaml index 472e40c..279f8c3 100644 --- a/.github/workflows/build_main.yaml +++ b/.github/workflows/build_main.yaml @@ -18,15 +18,16 @@ jobs: permissions: contents: write pages: write + pull-requests: write concurrency: group: ${{ github.workflow }}-${{ github.ref }} steps: - name: Checkout uses: actions/checkout@v4 - - name: Set up Python 3.10 + - name: Set up Python 3.12 uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" - name: Install dependencies run: | pip install -U pip @@ -38,11 +39,9 @@ jobs: SH_CLIENT_SECRET: ${{ secrets.SH_CLIENT_SECRET }} run: eodash_catalog - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - if: github.ref == 'refs/heads/main' + uses: JamesIves/github-pages-deploy-action@v4 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build - force_orphan: true - - + folder: ./build + branch: gh-pages + clean-exclude: pr-preview + force: false diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..0d88810 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,55 @@ +# .github/workflows/preview.yml +# This is a basic workflow takes care of building and deploying +# catalog when creating merge request + +name: Deploy PR previews + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed # pr-preview-action will do cleanup here, but build steps can be skipped + +# do not allow running multiple of pipelines for this PR in parallel +concurrency: preview-${{ github.ref }} + +jobs: + deploy-preview: + runs-on: ubuntu-22.04 + permissions: + contents: write + pages: write + pull-requests: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - if: github.event.action != 'closed' + name: Install dependencies + run: | + pip install -U pip + pip install -r requirements.txt + - if: github.event.action != 'closed' && (github.event.pull_request.body == 'all' || github.event.pull_request.body == '') + name: Build all collections + env: + SH_INSTANCE_ID: ${{ secrets.SH_INSTANCE_ID }} + SH_CLIENT_ID: ${{ secrets.SH_CLIENT_ID }} + SH_CLIENT_SECRET: ${{ secrets.SH_CLIENT_SECRET }} + run: eodash_catalog + - if: github.event.action != 'closed' && (github.event.pull_request.body != 'all' && github.event.pull_request.body != '') + name: Build only specified collections from PR comment text + env: + SH_INSTANCE_ID: ${{ secrets.SH_INSTANCE_ID }} + SH_CLIENT_ID: ${{ secrets.SH_CLIENT_ID }} + SH_CLIENT_SECRET: ${{ secrets.SH_CLIENT_SECRET }} + run: | + eodash_catalog ${{ github.event.pull_request.body }} + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./build diff --git a/README.md b/README.md index 26d5cdc..0d63be8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # catalog-template -Template for creating eodash catalog repository +Template for creating eodash catalog repository. ## How-to You can create a new repository using the "use this template" button.