From 91c59178de3238e861e1e6dfc56e9a739a0e0e3d Mon Sep 17 00:00:00 2001 From: ismay Date: Wed, 28 Aug 2024 11:20:24 +0200 Subject: [PATCH] ci: update to shared workflows --- .github/workflows/comment-and-close.yml | 13 +-- .github/workflows/deploy-pr.yml | 14 +++ .github/workflows/deploy-production.yml | 17 +++ .github/workflows/dhis2-verify-app.yml | 144 ------------------------ .github/workflows/lint-pr-title.yml | 13 +++ .github/workflows/test-and-release.yml | 22 ++++ 6 files changed, 72 insertions(+), 151 deletions(-) create mode 100644 .github/workflows/deploy-pr.yml create mode 100644 .github/workflows/deploy-production.yml delete mode 100644 .github/workflows/dhis2-verify-app.yml create mode 100644 .github/workflows/lint-pr-title.yml create mode 100644 .github/workflows/test-and-release.yml diff --git a/.github/workflows/comment-and-close.yml b/.github/workflows/comment-and-close.yml index 6aa782a08..6edcddd04 100644 --- a/.github/workflows/comment-and-close.yml +++ b/.github/workflows/comment-and-close.yml @@ -1,13 +1,12 @@ +name: comment-and-close + on: issues: types: [opened] jobs: comment-and-close: - runs-on: ubuntu-latest - steps: - - uses: vardevs/candc@v1 - with: - close-comment: 'If you would like to file a bug report or feature request, please refer to our issue tracker: https://jira.dhis2.org' - exempt-users: dhis2-bot,dependabot,kodiakhq - github-token: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}} + uses: dhis2/workflows-platform/.github/workflows/comment-and-close.yml@v1 + if: '!contains(github.event.issue.sender.login , fromJson(''["dhis2-bot", "kodiakhq", "dependabot"]''))' + with: + issue_number: ${{ github.event.issue.number }} diff --git a/.github/workflows/deploy-pr.yml b/.github/workflows/deploy-pr.yml new file mode 100644 index 000000000..fc915d195 --- /dev/null +++ b/.github/workflows/deploy-pr.yml @@ -0,0 +1,14 @@ +name: deploy-pr + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + deploy: + uses: dhis2/workflows-platform/.github/workflows/deploy-pr.yml@v1 + if: '!github.event.pull_request.head.repo.fork' + secrets: inherit diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml new file mode 100644 index 000000000..9575c2edb --- /dev/null +++ b/.github/workflows/deploy-production.yml @@ -0,0 +1,17 @@ +name: deploy-production + +on: + push: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + deploy: + uses: dhis2/workflows-platform/.github/workflows/deploy-production.yml@v1 + secrets: inherit + with: + branch: master diff --git a/.github/workflows/dhis2-verify-app.yml b/.github/workflows/dhis2-verify-app.yml deleted file mode 100644 index ea7a6742d..000000000 --- a/.github/workflows/dhis2-verify-app.yml +++ /dev/null @@ -1,144 +0,0 @@ -name: 'dhis2: verify (app)' - -on: - push: - branches: - -concurrency: - group: ${{ github.workflow}}-${{ github.ref }} - -env: - GIT_AUTHOR_NAME: '@dhis2-bot' - GIT_AUTHOR_EMAIL: 'apps@dhis2.org' - GIT_COMMITTER_NAME: '@dhis2-bot' - GIT_COMMITTER_EMAIL: 'apps@dhis2.org' - GH_TOKEN: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}} - CI: true - -jobs: - install: - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[skip ci]')" - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 12.x - - - uses: actions/cache@v2 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - with: - path: '**/node_modules' - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - - - name: Install - if: steps.yarn-cache.outputs.cache-hit != 'true' - run: yarn install --frozen-lockfile - - build: - runs-on: ubuntu-latest - needs: install - if: "!contains(github.event.head_commit.message, '[skip ci]')" - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 12.x - - - uses: actions/cache@v2 - id: yarn-cache - with: - path: '**/node_modules' - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - - - name: Build - run: yarn build - - - uses: actions/upload-artifact@v2 - with: - name: app-build - path: | - **/build - !**/node_modules - retention-days: 1 - - lint: - runs-on: ubuntu-latest - needs: install - if: "!contains(github.event.head_commit.message, '[skip ci]')" - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 12.x - - - uses: actions/cache@v2 - id: yarn-cache - with: - path: '**/node_modules' - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - - - name: Lint - run: yarn lint - - test: - runs-on: ubuntu-latest - needs: install - if: "!contains(github.event.head_commit.message, '[skip ci]')" - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 12.x - - - uses: actions/cache@v2 - id: yarn-cache - with: - path: '**/node_modules' - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - - - name: Test - run: yarn test - - publish: - runs-on: ubuntu-latest - needs: [build, lint, test] # add e2e if you use it - if: "!contains(github.event.head_commit.message, '[skip ci]')" - steps: - - uses: actions/checkout@v2 - with: - token: ${{env.GH_TOKEN}} - - - uses: actions/setup-node@v1 - with: - node-version: 12.x - - - uses: actions/download-artifact@v2 - with: - name: app-build - - - uses: dhis2/deploy-build@master - with: - # uncomment following line for monorepo apps: - #cwd: ./packages/app - # for app platform use: - #build-dir: build/app - build-dir: build - github-token: ${{ env.GH_TOKEN }} - - release: - runs-on: ubuntu-latest - needs: [publish] - if: "github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip ci]')" - steps: - - uses: actions/checkout@v2 - with: - token: ${{env.GH_TOKEN}} - - - uses: actions/setup-node@v1 - with: - node-version: 12.x - - - name: Publish release to GitHub - run: npx @dhis2/cli-utils release diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 000000000..eb59072b9 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -0,0 +1,13 @@ +name: lint-pr-title + +on: + pull_request: + types: ['opened', 'edited', 'reopened', 'synchronize'] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + lint-pr-title: + uses: dhis2/workflows-platform/.github/workflows/lint-pr-title.yml@v1 diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 000000000..9e05061cb --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,22 @@ +name: test-and-release + +on: push + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + # Cancel previous runs if not on a release branch + cancel-in-progress: ${{ !contains(fromJSON('["refs/heads/master", "ref/heads/main"]'), github.ref) }} + +jobs: + lint-commits: + uses: dhis2/workflows-platform/.github/workflows/lint-commits.yml@v1 + lint: + uses: dhis2/workflows-platform/.github/workflows/lint.yml@v1 + test: + uses: dhis2/workflows-platform/.github/workflows/test.yml@v1 + release: + needs: [lint-commits, lint, test] + uses: dhis2/workflows-platform/.github/workflows/release.yml@v1 + # Skips forks and dependabot PRs + if: '!github.event.push.repository.fork' + secrets: inherit