From 73b7173b67af4e39998ddca6c4006a9d7d021455 Mon Sep 17 00:00:00 2001 From: jennylsmith Date: Tue, 25 Feb 2025 17:54:37 -0800 Subject: [PATCH 1/2] check gh cli status and restore artifacts in deploy step --- .github/workflows/quarto.yml | 110 ++++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 29 deletions(-) diff --git a/.github/workflows/quarto.yml b/.github/workflows/quarto.yml index 3e290f9..f8780a1 100644 --- a/.github/workflows/quarto.yml +++ b/.github/workflows/quarto.yml @@ -4,7 +4,13 @@ name: quarto-website on: # Triggers the workflow on push or pull request events but only for the specified branches push: - branches: [ "main", "dev", "main_pr_test", "dev_pr_test"] + branches: + - dev_pr_test + # - dev* + - feat/* + pull_request_target: + branches: + - main_pr_test # Allows you to run this workflow manually from the Actions tab or gh CLI workflow_dispatch: @@ -21,16 +27,19 @@ permissions: id-token: write pull-requests: write +env: + QUARTO_VERSION: 1.5.57 + OUTPUT_DIR: docs + CACHE_PATH: '**/docs/*.*' + BASE: dev_pr_test + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: + # if: github.event_name == 'push' # This workflow contains a single job called "build" build: # The type of runner that the job will run on runs-on: ubuntu-latest - env: - QUARTO_VERSION: 1.5.57 - OUTPUT_DIR: docs - CACHE_PATH: '**/docs/*.*' # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -43,7 +52,8 @@ jobs: - name: setup pages id: pages uses: actions/configure-pages@v5 - + + # check if the artifacts for that commit exist already - name: restore artifacts id: cache-artifacts uses: actions/cache/restore@v4 @@ -80,42 +90,42 @@ jobs: # pull request # https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs - pull_request: - if: ${{ github.ref_name == 'dev_pr_test' }} + create_pull_request: + # if: ${{ github.ref_name == 'dev_pr_test' }} needs: build runs-on: ubuntu-latest environment: name: dev - env: - BASE: main_pr_test + steps: - name: checkout uses: actions/checkout@v4 with: token: ${{ secrets.GH_PAT }} - ref: main_pr_test + ref: ${{ env.BASE }} + - name: gh-cli-pr run: | echo ${{ secrets.GH_PAT }} | gh auth login --with-token && \ - gh pr create -B $BASE -H ${{ github.ref_name }} --title "PR for ${{ github.sha }} on RUN_ID ${{ github.run_id }}" --body "PR for ${{ github.sha }}" --draft && \ + gh pr create -B $BASE -H ${{ github.ref_name }} --title "PR for RUN_ID ${{ github.run_id }}" --body "PR for ${{ github.sha }}" --draft && \ gh auth logout - # - name: gh-cli-pr - # run: - - # - name: create-pull-request - # id: cpr - # uses: peter-evans/create-pull-request@v7 - # with: - # commit-message: merge dev into main - # title: PR from ${{ github.run_id }} - # draft: always-true - # branch: ${{ github.ref }} + + - name: gh-cli-check + run: | + gh auth status + + - name: pr-info + run: | + echo the PR number is ${{ github.event.pull_request.number }} + # deploy job deploy: - if: ${{ github.ref_name == 'main' }} + # if: ${{ github.event_name == 'pull_request_target' && github.ref_name == 'dev_pr_test' }} + # Add a dependency to the job - needs: build + needs: create_pull_request + # Deploy to the github-pages environment # Settings and variables here: https://github.com/jennylsmith/jennylsmith.github.io/settings/environments # environment: @@ -123,14 +133,22 @@ jobs: # url: ${{ steps.deployment.outputs.page_url }} environment: name: dev + # Specify runner runs-on: ubuntu-latest # deploy to gh pages - steps: - - name: "vars example" + steps: + - name: restore artifacts + id: cache-artifacts + uses: actions/cache/restore@v4 + with: + path: ${{ env.OUTPUT_DIR }} + key: ${{ github.ref_name }}-${{ github.sha }}-key + + - name: check-vars run: | - echo "the gh branch that triggered the workflow is $GITHUB_REF_NAME" - echo "debug set to $ACTIONS_RUNNER_DEBUG" + ls -alh + # - name: deploy to GitHub pages # id: deployment # uses: actions/deploy-pages@v4 @@ -151,3 +169,37 @@ jobs: # repository or environment variables can be set on Github or the GH Actions extension in VSCode # https://github.com/jennylsmith/jennylsmith.github.io/settings/variables/actions # if statements can only access thse expression contexts: github, inputs, vars, needs + +## OUTPUTS and gh CLI + +# FIELDS=$(gh pr view 8 --json closed,state | sed -E 's/{|}//g' | tr -d '"') +# echo $FIELDS | while IFS=':|,' read CLOSED CL_STATUS STATE MERGED +# do; +# CLOSED_STATUS=$(test "$CL_STATUS" = "true" | echo $?) +# MERGED_STATUS=$(test "$MERGED" = "MERGED" | echo $?) +# done; + + +# gh pr view --repo nf-core/demultiplex 315 --json closed,state | sed -E 's/{|}//g' + +# # .github/workflows/reusable-workflow.yml +# name: Reusable Workflow +# on: +# workflow_call: +# outputs: +# example_output: +# description: "An example output" + +# jobs: +# build: +# runs-on: ubuntu-latest + +# steps: +# - name: Set output +# id: set_output +# run: echo "::set-output name=example_output::Hello, World!" + +# outputs: +# example_output: ${{ steps.set_output.outputs.example_output }} + + From 081fb21e15d8c1ceebf7dcc869715972777c7a2e Mon Sep 17 00:00:00 2001 From: jennylsmith Date: Tue, 25 Feb 2025 18:03:13 -0800 Subject: [PATCH 2/2] use simpler cache key for now --- .github/workflows/quarto.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/quarto.yml b/.github/workflows/quarto.yml index f8780a1..51d6b70 100644 --- a/.github/workflows/quarto.yml +++ b/.github/workflows/quarto.yml @@ -31,6 +31,7 @@ env: QUARTO_VERSION: 1.5.57 OUTPUT_DIR: docs CACHE_PATH: '**/docs/*.*' + CACHE_KEY: ${{ github.ref_name }}-key BASE: dev_pr_test # A workflow run is made up of one or more jobs that can run sequentially or in parallel @@ -59,7 +60,7 @@ jobs: uses: actions/cache/restore@v4 with: path: ${{ env.OUTPUT_DIR }} - key: ${{ github.ref_name }}-${{ github.sha }}-key + key: ${{ env.CACHE_KEY }} # install quarto - name: install quarto CLI @@ -86,7 +87,7 @@ jobs: uses: actions/cache/save@v4 with: path: ${{ env.OUTPUT_DIR }} - key: ${{ github.ref_name }}-${{ github.sha }}-key + key: ${{ env.CACHE_KEY }} # pull request # https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs @@ -110,15 +111,6 @@ jobs: gh pr create -B $BASE -H ${{ github.ref_name }} --title "PR for RUN_ID ${{ github.run_id }}" --body "PR for ${{ github.sha }}" --draft && \ gh auth logout - - name: gh-cli-check - run: | - gh auth status - - - name: pr-info - run: | - echo the PR number is ${{ github.event.pull_request.number }} - - # deploy job deploy: # if: ${{ github.event_name == 'pull_request_target' && github.ref_name == 'dev_pr_test' }} @@ -143,7 +135,7 @@ jobs: uses: actions/cache/restore@v4 with: path: ${{ env.OUTPUT_DIR }} - key: ${{ github.ref_name }}-${{ github.sha }}-key + key: ${{ env.CACHE_KEY }} - name: check-vars run: | @@ -154,6 +146,7 @@ jobs: # uses: actions/deploy-pages@v4 + #### NOTES # Debugging log info