Skip to content

Commit

Permalink
fix: display correct app version in dhis2 and updated workflows (#3061)
Browse files Browse the repository at this point in the history
PR workflow: verify-pr.yml
This workflow triggers on pull request actions only.
It verifies that the PR code passes build, lint, test, and e2e.

Release workflow: release.yml
This workflow only runs on pushes to the master branch since this is the only
release branch. Every release involves 2 commits to master:
* squash merging the PR
* the release workflow pushes a new commit with version change in package.json
and CHANGELOG.md, e.g. the [skip release] commit

The release workflow triggers for both pushes to master listed above.
But the release job should only run for the first push.

The semantic-release workflow steps are found in .releaserc.
Previously @dhis2/action-semantic-release was used but this was overkill
for our needs and difficult to make changes to.
Therefore, we created our own semantic-release steps in .releaserc:
* commit-analyzer: Determines the next app version
* release-notes-generator: Generates the new release notes
* changelog: Updates CHANGELOG.md with the generated release notes
* npm: Updates package.json with the new version number.
Does not publish to npm since private: true in package.json
exec: Runs yarn build which updates all version number references in the bundle
* git: creates commit number "2" (mentioned above) with just
CHANGELOG.md and package.json and pushes it to the remote
* github: pushes the bundle to the github repo as a new release and adds a tag

After semantic-release is complete, the bundle is then published to AppHub
so that it is actually available to all users. Because of the addition of the exec
yarn build step, all references to the version in the bundle should be the same,
thus fixing the annoying bug where the old version displays in the instance
after installing the later version.

If any point in the release fails, then a failure message is sent to slack.
If the release step succeeds, then a success message is posted to slack that
includes the new version number and the release notes.

Publish to d2-ci: publish-to-d2-ci.yml
Publishes the build to d2-ci in the following cases:
* The [skip release] commit on master
* Git tags

Fail message is sent to slack if the publish failed
  • Loading branch information
jenniferarnesen authored Aug 23, 2024
1 parent c12e71c commit 69b8425
Show file tree
Hide file tree
Showing 5 changed files with 345 additions and 238 deletions.
238 changes: 0 additions & 238 deletions .github/workflows/dhis2-verify-app.yml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/publish-d2-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 'publish build to d2-ci'

on:
push:
branches:
- master
tags:
- '*'

env:
GIT_AUTHOR_NAME: '@dhis2-bot'
GIT_AUTHOR_EMAIL: '[email protected]'
GIT_COMMITTER_NAME: '@dhis2-bot'
GIT_COMMITTER_EMAIL: '[email protected]'
GH_TOKEN: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}}
CI: true

jobs:
publish-to-d2-ci:
if: |
${{ !github.event.push.repository.fork }} &&
${{ github.actor == 'dhis2-bot' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }}
runs-on: ubuntu-latest
steps:
- name: Print GitHub event context
run: echo "$GITHUB_EVENT" | jq '.'
env:
GITHUB_EVENT: ${{ toJson(github.event) }}

- name: Print GitHub ref
run: echo "GITHUB_REF is $GITHUB_REF" and actor is ${{ github.actor }}

- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install
run: yarn install --frozen-lockfile

- name: Build
run: yarn d2-app-scripts build

- name: Copy build to d2-ci
uses: dhis2/deploy-build@master
with:
build-dir: build/app
github-token: ${{ secrets.DHIS2_BOT_GITHUB_TOKEN }}

report-deploy-failure:
runs-on: ubuntu-latest
needs: publish-to-d2-ci
if: ${{ failure() && !cancelled() }}
steps:
- name: Send failure message to analytics-internal-bot slack channel
id: slack_publish_failure
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"text": ":small_red_triangle_down: :dashboard-app: Dashboard failed to deploy to d2-ci",
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
Loading

0 comments on commit 69b8425

Please sign in to comment.