Skip to content

Update ci.yml

Update ci.yml #75

Workflow file for this run

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
CI_COMMIT_AUTHOR: github-actions[bot]
CI_COMMIT_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
steps:
- name: checkout specific files
id: checkout-files
uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ env.DEST_BRANCH }}
- name: create branch from destination branch and checkout files from base branch
id: new-branch
run: |
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git fetch origin
git push -d origin $TEMP_BRANCH &>/dev/null || true
git branch -d $TEMP_BRANCH &>/dev/null || true
git checkout -b $TEMP_BRANCH
git checkout $BASE_BRANCH -- .github/workflows src/_data src/pages/api src/_includes/modules/api-config.njk
git add -A
git commit -m "CI: automatically update ${{ env.DEST_BRANCH }} from ${{ env.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 $DEST_BRANCH" --body "Automated PR Created by Github action" --draft --label "automation" --reviewer "rediris"
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 }}