From 0d61b65b396a3898d6759034abef771a4be01920 Mon Sep 17 00:00:00 2001 From: RokGrah <69851279+RokGrah@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:30:32 +0100 Subject: [PATCH] Create workflow_submit_model_forecasts.yml --- .../workflow_submit_model_forecasts.yml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/workflow_submit_model_forecasts.yml diff --git a/.github/workflows/workflow_submit_model_forecasts.yml b/.github/workflows/workflow_submit_model_forecasts.yml new file mode 100644 index 0000000..428ec31 --- /dev/null +++ b/.github/workflows/workflow_submit_model_forecasts.yml @@ -0,0 +1,76 @@ + name: Submit_RespiCast_Forecasts + # Firts step is to define di events that can trigger this workflow + on: + # Run upon previous GenerateModelOutput completion + workflow_run: + workflows: [Generate_RespiCast_Forecasts] + types: + - completed + # Or you can manually trigger the workflow + workflow_dispatch: + + jobs: + create_PR_job: + runs-on: ubuntu-latest + steps: + + # Checkout your forked repository - main branch - + # where this action is currently hosted + # --------------------------------------------------- + - name: checkout forked repository + uses: actions/checkout@v3 + with: + ref: main + token: ${{ secrets.GITHUB_TOKEN }} + + # Checkout the model data repository - main branch - + # This is the repository where previous wf saved the model output data + # In this example data repo is https://github.com/your_organization/data-repo + # ----------------------------------------------------------------------------- + - name: checkout data repository + uses: actions/checkout@v3 + with: + ref: 'main' # the git branch to work on + token: ${{ secrets.GITHUB_TOKEN }} + repository: 'EU-ECDC/ECDC-Mathematical-Models' + path: './data-repo/' # Relative path under $GITHUB_WORKSPACE to place the repository + + + + # Set the default remote repository to use when querying the GitHub API for the locally cloned repository. + - run: gh repo set-default european-modelling-hubs/flu-forecast-hub + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + + # Sync forked repo main branch, pull and then switch to a new brench + - run: | + git config --global user.email "YourGitHubUserEmail" + git config --global user.name "YourGitHubUserName" + gh repo sync your_organization/flu-forecast-hub -b main + git pull + git checkout -b my-branch + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # make a copy of the needed files from source repo to local fork + - name: Copy model-output file + run: cp ./data-repo/model-output_filepath local_fliepath + + # commit change to a new brach! This step is needed in order + # to succesfully open the subsequent pull request + - run: | + git add local_fliepath + git commit -m "Git Commit comment" + git push -u origin my-branch + + + # Finally, open the pull request from local my-branch to the main branch + # secrets.MY_PAT_SECRET is a repository secret you have to create in your forked repository + # containing a valid PERSONAL ACCESS TOKEN for YourGitHubUserName. + # Without this secret the pr create fails with "Resource not accessible by integration" error + - name: Open the pull requests + run: gh pr create --head YourGitHubUserName:my-branch --base main --title 'PR Title' --body 'PR Body' + env: + GH_TOKEN: ${{ secrets.MY_PAT_SECRET }}