Initial commit #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create initialization issue on repository dispatch | |
on: | |
push: | |
branches: main | |
jobs: | |
create_issue: | |
runs-on: ubuntu-latest | |
if: ${{ github.repository != 'HakaiInstitute/hakai-dataset-repository-template' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create issue | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.CI_TOKEN}} | |
script: | | |
const fs = require('fs') | |
const org = 'HakaiInstitute' | |
const team_slug = 'data-mobilization-team' | |
const teamMembers = await github.rest.teams.listMembersInOrg({ | |
org, | |
team_slug, | |
}) | |
const reviewer = teamMembers.data.map(member => member.login) | |
// Read the issue body from a file | |
const issueBody = fs.readFileSync('.github/ISSUE_TEMPLATE/init-data-repository-body.md', 'utf8') | |
const issue = { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: 'Initialize dataset repository', | |
body: issueBody, | |
assignees: reviewer, | |
} | |
github.rest.issues.create(issue) | |
- name: Cleanup repository initialization files | |
run: | | |
rm -rf .github/workflows/init-dataset-repo.yaml | |
rm -rf .github/ISSUE_TEMPLATE/init-data-repository-body.md | |
sed -i 's|# hakai-dataset-repository-template|# ${{ github.repository }}|g' README.md | |
- name: Change CODEOWNER to github actor | |
run: | | |
echo "* @$GITHUB_ACTOR" > CODEOWNERS | |
- name: Commit and push changes | |
uses: stefanzweifel/git-auto-commit-action@v5 |