DIAGNijmegen / website-content

This repository stores all the content for the diag websites.
MIT License
5 stars 74 forks source link

Check if new commits do not remove members #479

Open JoeySpronck opened 1 year ago

JoeySpronck commented 1 year ago

Now it could be that people remove members once they leave. But the profile page should be set to inactive. And member should be added to former employees.

keelinm commented 1 year ago

build should fail if a member page is deleted (during build, check the list of existing member pages and previous member pages and verify one is not removed??)

drepeeters commented 1 year ago

I've tried using the GitPython API to check for differences between new and previous commits. With a locap git repository it was able to detect deleted files. However, while running in a github workflow a new 'local' repository is created inside a docker I believe. Therefore this new 'local' repository can be seen as the first version and therefore has no previous version to compare differences with.

drepeeters commented 1 year ago

As you may have seen I was able to post notification in the webteam channel. However, it also posted a notification in case a new member file is added. This is ofcourse not what we want, this was the result of a forgotten "if-statement" in the workflow action.

The following code has to be updated so that it include an if-statement associated with a deleted file:

name: Member removal notification
on:
  push:
    branches: 
      - main
    paths:
      - 'contents/**'
  workflow_dispatch:

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:        
      - name: Notify dedicated teams channel
        if: **insert if-statement here**
        uses: jdcargile/ms-teams-notification@v1.3
        with:
          github-token: ${{ github.token }} # this will use the runner's token.
          ms-teams-webhook-uri: ${{ secrets.TEAMS_CHANNEL_WEBHOOK_URL }}
          notification-summary: 'Warning! A member file has been removed. Contact someone from the Webteam and make sure the member is added back.'
          notification-color: 17a2b8