Update ci.yml #68
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: Changed Data Files - Develop | |
on: | |
push: | |
branches: | |
- dev/test/api | |
paths: | |
- '.github/workflows/**' | |
- 'src/_data/**.js' | |
- 'src/_data/**.yml' | |
- 'src/pages/api/**.njk' | |
- 'src/_includes/modules/api-config.njk' | |
jobs: | |
automatic-pr: | |
runs-on: ubuntu-latest # windows-latest || macos-latest | |
name: Automatic PR | |
env: | |
TEMP_BRANCH: auto/dev/test/api | |
BASE_BRANCH: origin/develop | |
DEST_BRANCH: api/dev | |
steps: | |
- name: checkout specific files | |
id: checkout-files | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
ref: ${{ env.DEST_BRANCH }} | |
# sparse-checkout: | | |
# .github/workflows/ | |
# src/_data/ | |
# src/pages/api/ | |
# src/_includes/modules/api-config.njk | |
# sparse-checkout-cone-mode: false | |
- name: create new branch | |
id: new-branch | |
run: | | |
git checkout -b $TEMP_BRANCH | |
git checkout $BASE_BRANCH -- .github/workflows src/_data src/pages/api src/_includes/modules/api-config.njk | |
git commit -m "auto: add updated files from $BASE_BRANCH" | |
git push --set-upstream origin $TEMP_BRANCH | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: set datestamp | |
id: datestamp | |
run: | | |
echo "datestamp=$(git log -1 --format=%cd --date=format:%Y-%m-%d-%H%M%S)" >> $GITHUB_OUTPUT | |
- name: create pull request | |
run: gh pr create -B $DEST_BRANCH -H $TEMP_BRANCH --title "[Auto PR] - ${{ steps.datestamp.outputs.datestamp }} Merge $TEMP_BRANCH into api/dev" --body "Automated PR Created by Github action" --draft --label "automation" --reviewer "rediris" --dry-run | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# create_pr: | |
# runs-on: ubuntu-latest | |
# name: Create PR | |
# steps: | |
# - name: sparse checkout api/dev branch | |
# uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 0 | |
# ref: api/dev | |
# sparse-checkout: | | |
# .github/workflows/** | |
# src/_data/**.js | |
# src/_data/**.yml | |
# src/pages/api/**.njk | |
# /src/_includes/modules/api-config.njk | |
# sparse-checkout-cone-mode: false | |
# - name: create temp branch | |
# uses: carlsberg/[email protected] | |
# id: temp-branch | |
# with: | |
# base: api/dev | |
# - name: checkout specific files in develop branch | |
# run: | | |
# git checkout ${{ steps.temp-branch.outputs.branch }} | |
# git checkout develop -- .github/workflows/** src/_data/**.js src/_data/**.yml src/pages/api/**.njk /src/_includes/modules/api-config.njk | |
# - name: set datestamp | |
# id: datestamp | |
# run: | | |
# echo "datestamp=$(git log -1 --format=%cd --date=format:%Y-%m-%dh%H%M%S)" >> $GITHUB_OUTPUT | |
# - name: set PR message | |
# id: message | |
# run: | | |
# title="[Auto PR]: ${{ steps.datestamp.outputs.datestamp }} Update API - Dev" | |
# body="This PR was auto-generated on ${{ steps.datestamp.outputs.datestamp }} \ | |
# by [create-pull-request](https://github.com/peter-evans/create-pull-request)." | |
# echo "title=$title" >> $GITHUB_OUTPUT | |
# echo "body=$body" >> $GITHUB_OUTPUT | |
# - name: Create Pull Request | |
# uses: peter-evans/create-pull-request@v7 | |
# with: | |
# branch: auto/api/dev | |
# title: ${{ steps.message.outputs.title }} | |
# body: ${{ steps.message.outputs.body }} |