From 268dd8f7dfbba15e24b792f1f44efabe784bcb3a Mon Sep 17 00:00:00 2001 From: Kai Henseler Date: Tue, 23 Jul 2024 10:07:10 +0200 Subject: [PATCH] ci(header): adds actions to lint and build Signed-off-by: Kai Henseler --- .github/workflows/header-building.yml | 57 +++++++++++++++++++++++++++ .github/workflows/header-linting.yml | 26 ++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 .github/workflows/header-building.yml create mode 100644 .github/workflows/header-linting.yml diff --git a/.github/workflows/header-building.yml b/.github/workflows/header-building.yml new file mode 100644 index 0000000..d882749 --- /dev/null +++ b/.github/workflows/header-building.yml @@ -0,0 +1,57 @@ +name: Header - Build + +on: + pull_request: + branches: + - main + paths: + - "IONOS/**" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install dependencies + run: cd IONOS/ && npm ci + + - name: Run lint + run: cd IONOS/ && npm run lint + + - name: Check if Header was not built + run: | + CORE_JS_CHANGES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -e '^core/js/custom-elements/global-navigation/') + if [[ -n "$CORE_JS_CHANGES" ]]; then + echo "CORE_JS_CHANGED=true" >> $GITHUB_ENV + else + echo "CORE_JS_CHANGED=false" >> $GITHUB_ENV + fi + + - name: Run build + if: env.CORE_JS_CHANGED == 'false' + run: cd IONOS/ && npm run build + + - name: Push changes to branch auto-build-${{ github.head_ref }}-output + if: env.CORE_JS_CHANGED == 'false' + run: | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + git checkout -b auto-build-${{ github.head_ref }}-output + git add core/js/custom-elements/global-navigation/ionos-global-navigation.js + git commit -sm "build(header): automatic header build ${{ github.head_ref }}" + git push origin auto-build-${{ github.head_ref }}-output + + - name: Remind to create a pull request + if: env.CORE_JS_CHANGED == 'false' + run: | + Looks like you forgot to build the new header. + I built it so you can pull it from auto-build-${{ github.head_ref }}-output diff --git a/.github/workflows/header-linting.yml b/.github/workflows/header-linting.yml new file mode 100644 index 0000000..f1bb53d --- /dev/null +++ b/.github/workflows/header-linting.yml @@ -0,0 +1,26 @@ +name: Header - Code Quality + +on: + push: + paths: + - "IONOS/**" + +jobs: + code-quality: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install Dependencies + run: cd IONOS/ && npm ci + + - name: Lint Headers + run: cd IONOS/ && npm run lint + + - name: Prettier + run: cd IONOS/ && npm run format:check