Skip to content

Commit

Permalink
Merge pull request #12 from joshjohanning/update-workflow
Browse files Browse the repository at this point in the history
feat: updating github actions workflow
  • Loading branch information
joshjohanning authored Nov 13, 2024
2 parents 3a893ad + 840f325 commit 1a77fb1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 46 deletions.
70 changes: 37 additions & 33 deletions .github/workflows/migrate-work-items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
description: tag migrated work items with migrated-to-github and add discussion comment
required: true
type: boolean
default: 'true'
default: 'false'
gh-org:
description: 'gh-org'
required: true
Expand Down Expand Up @@ -53,40 +53,44 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@main

- uses: tibdex/github-app-token@v1
id: get_installation_token
with:
app_id: 179484
installation_id: 23995058
private_key: ${{ secrets.PRIVATE_KEY }}
- uses: actions/checkout@v4

- name: get az and az devops version
run: az --version

- name: get gh version
run: gh --version

# doesn't work with the (unofficial) issue migration API?
# - uses: actions/create-github-app-token@v1
# id: app-token
# with:
# app-id: 179484 # work-item-migrator
# private-key: ${{ secrets.PRIVATE_KEY }}
# owner: ${{ github.repository_owner }}

- name: run migration
shell: pwsh
shell: bash
run: |
# run migration script
$ado_migrate_closed_workitems_param=""
$ado_production_run_param=""
$gh_update_assigned_to_param=""
$gh_add_ado_comments_param=""
if("${{ github.event.inputs.ado_migrate_closed_workitems }}" -eq "true") {
$ado_migrate_closed_workitems_param="-ado_migrate_closed_workitems"
}
ado_migrate_closed_workitems_param=""
ado_production_run_param=""
gh_update_assigned_to_param=""
gh_add_ado_comments_param=""
if [ "${{ github.event.inputs.ado_migrate_closed_workitems }}" == "true" ]; then
ado_migrate_closed_workitems_param="--ado_migrate_closed_workitems"
fi
if [ "${{ github.event.inputs.ado_production_run }}" == "true" ]; then
ado_production_run_param="--ado_production_run"
fi
if [ "${{ github.event.inputs.gh_update_assigned_to }}" == "true" ]; then
gh_update_assigned_to_param="--gh_update_assigned_to"
fi
if("${{ github.event.inputs.ado_production_run }}" -eq "true") {
$ado_production_run_param="-ado_production_run"
}
if [ "${{ github.event.inputs.gh_add_ado_comments }}" == "true" ]; then
gh_add_ado_comments_param="--gh_add_ado_comments"
fi
if("${{ github.event.inputs.gh_update_assigned_to }}" -eq "true") {
$gh_update_assigned_to_param="-gh_update_assigned_to"
}
if("${{ github.event.inputs.gh_add_ado_comments }}" -eq "true") {
$gh_add_ado_comments_param="-gh_add_ado_comments"
}
./ado_workitems_to_github_issues.ps1 -ado_pat "${{ SECRETS.ADO_PAT }}" -ado_org "${{ github.event.inputs.ado-org }}" -ado_project "${{ github.event.inputs.ado-project }}" -ado_area_path "${{ github.event.inputs.ado_area_path }}" $ado_migrate_closed_workitems_param $ado_production_run_param -gh_pat "${{ steps.get_installation_token.outputs.token }}" -gh_org "${{ github.event.inputs.gh-org }}" -gh_repo "${{ github.event.inputs.gh-repo }}" $gh_update_assigned_to_param -gh_assigned_to_user_suffix "${{ github.event.inputs.gh_assigned_to_user_suffix }}" $gh_add_ado_comments_param
pwsh ./ado_workitems_to_github_issues.ps1 -ado_pat "${{ secrets.ADO_PAT }}" -ado_org "${{ github.event.inputs.ado-org }}" -ado_project "${{ github.event.inputs.ado-project }}" -ado_area_path "${{ github.event.inputs.ado_area_path }}" $ado_migrate_closed_workitems_param $ado_production_run_param -gh_pat "${{ secrets.GH_PAT }}" -gh_org "${{ github.event.inputs.gh-org }}" -gh_repo "${{ github.event.inputs.gh-repo }}" $gh_update_assigned_to_param -gh_assigned_to_user_suffix "${{ github.event.inputs.gh_assigned_to_user_suffix }}" $gh_add_ado_comments_param
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,16 @@ PowerShell script to migrate Azure DevOps work items to GitHub Issues

The recommendation is to use a GitHub App to run the migration - a GitHub app has higher rate limits than using a user PAT.

1. Create GitHub App with (can use this [reference](https://josh-ops.com/posts/github-apps/#creating-a-github-app)). Use the following permissions:
+ Repo: `Contents:Read`
+ Repo: `Issues:Read and write`
+ Org: `Members:Read`
1. Create Private Key for GitHub App
1. Obtain App ID and Installation ID - see [the instructions for using smee.io](https://josh-ops.com/posts/github-apps/#creating-a-github-app)
1. Create the following action secrets:
+ `ADO_PAT`: Azure DevOps PAT with appropriate permissions to read work and write items
+ `PRIVATE_KEY`: The contents of the private key created and downloaded in step #2
1. Use the [action](.github/workflows/migrate-work-items.yml) and update the App ID and Installation ID obtained in step #3
1. Update any defaults in the [action](.github/workflows/migrate-work-items.yml) (ie: Azure DevOps organization and project, GitHub organization and repo)
1. Ensure the action exists in the repo's default branch
1. Run the workflow
1. Create a (classic) GitHub personal access token with at least the following scopes:
+ `repo` (all scopes here)
+ `read:org`
2. Create the following action secrets:
+ `ADO_PAT`: Azure DevOps PAT with appropriate permissions to read work items
+ `GH_PAT`: The value of the PAT created in step #1
3. Use the [action](.github/workflows/migrate-work-items.yml)
4. Update any defaults in the [action](.github/workflows/migrate-work-items.yml) (ie: Azure DevOps organization and project, GitHub organization, repo, and any other defaults you want changed)
5. Ensure the action exists in the repo's default branch
6. Run the workflow

## Instructions for Running Locally

Expand Down

0 comments on commit 1a77fb1

Please sign in to comment.