|
| 1 | +# This is a manua workflow that does the following when trigerred: |
| 2 | +# - Runs a script to find and replace Go import path major version with given version. |
| 3 | +# - Commits and pushes changes to the source-branch. |
| 4 | +# - Opens a PR from the source branch to the target-branch. |
| 5 | + |
| 6 | +name: Update Go Import Paths |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'Current Version that we want to change' |
| 13 | + default: '10' |
| 14 | + required: true |
| 15 | + target-branch: |
| 16 | + description: 'Target Branch' |
| 17 | + default: 'main' |
| 18 | + required: true |
| 19 | + source-branch: |
| 20 | + description: 'Source Branch' |
| 21 | + default: 'update-paths' |
| 22 | + required: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + update-import-paths: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - |
| 30 | + name: Check out repository code |
| 31 | + uses: actions/checkout@v2 |
| 32 | + - |
| 33 | + name: Setup Golang |
| 34 | + uses: actions/setup-go@v2.1.4 |
| 35 | + with: |
| 36 | + go-version: 1.18 |
| 37 | + - |
| 38 | + name: Display go version |
| 39 | + run: go version |
| 40 | + - |
| 41 | + name: Get data from build cache |
| 42 | + uses: actions/cache@v2 |
| 43 | + with: |
| 44 | + # In order: |
| 45 | + # * Module download cache |
| 46 | + # * Build cache (Linux) |
| 47 | + # * Build cache (Mac) |
| 48 | + # * Build cache (Windows) |
| 49 | + path: | |
| 50 | + ~/go/pkg/mod |
| 51 | + ~/.cache/go-build |
| 52 | + ~/Library/Caches/go-build |
| 53 | + ~\AppData\Local\go-build |
| 54 | + key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} |
| 55 | + restore-keys: | |
| 56 | + ${{ runner.os }}-go-${{ matrix.go-version }}- |
| 57 | + - |
| 58 | + name: Run find & replace script |
| 59 | + run: ./scripts/replace_import_paths.sh ${{ inputs.version }} |
| 60 | + - name: Create Pull Request |
| 61 | + uses: peter-evans/create-pull-request@v4 |
| 62 | + with: |
| 63 | + token: ${{ secrets.ADD_TO_PROJECT_PAT }} |
| 64 | + title: "auto: update Go import paths to v${{ inputs.version }}" |
| 65 | + commit-message: "auto: update Go import paths to v${{ inputs.version }}" |
| 66 | + body: "**Automated pull request**\n\nUpdating Go import paths to v${{ inputs.version }}" |
| 67 | + base: ${{ inputs.target-branch }} |
| 68 | + branch-suffix: random |
| 69 | + branch: ${{ inputs.source-branch }} |
| 70 | + delete-branch: true |
| 71 | + assignees: ${{ github.actor }} |
| 72 | + draft: true |
| 73 | + labels: T:auto,T:code-hygiene |
0 commit comments