Skip to content

Commit

Permalink
feat: Set up continuous integration
Browse files Browse the repository at this point in the history
- remove unused blog.json file
  • Loading branch information
rediris committed Jan 14, 2025
1 parent 2a053db commit 362eeb2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 337 deletions.
73 changes: 38 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,58 @@ name: Changed Data Files - Develop
on:
push:
branches:
- develop
- dev/test/api
paths:
- '.github/workflows/**'
- 'src/_data/**.js'
- 'src/_data/**.yml'
- 'src/pages/api/**.njk'
- 'src/_includes/modules/api-config.njk'
- 'src/_includes/modules/components/**'

jobs:
create_pr:
automatic-pr:
runs-on: ubuntu-latest
name: Create PR
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
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: sparse checkout api/dev branch
uses: actions/checkout@v4
- name: checkout specific files
id: checkout-files
uses: actions/[email protected]
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
ref: ${{ env.DEST_BRANCH }}
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
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
format: YYYYMMDD-HHMMSS
timezone: America/New_York
- name: set commit/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)."
title="✅ CI: automatically update ${{ env.DEST_BRANCH }} from ${{ env.BASE_BRANCH }} 🙌📟🎉"
body="🚀 Automated PR created via Github action by ${{ env.CI_COMMIT_AUTHOR }} :octocat: on ${{ steps.current-time.outputs.readableTime }} 📅⏳"
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 }}
- 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 src/_includes/modules/components
git add -A
git commit -m "${{ steps.message.outputs.title }}"
git push --set-upstream origin $TEMP_BRANCH
- name: create pull request
run: gh pr create -B $DEST_BRANCH -H $TEMP_BRANCH --title "${{ steps.message.outputs.title }}" --body "${{ steps.message.outputs.body }}" --draft --label "automation" --reviewer "rediris"
Loading

0 comments on commit 362eeb2

Please sign in to comment.