Skip to content

Commit 3838b74

Browse files
authored
Deprecate default name of prebuilt branch (#1811)
* Improve traceability (bootstrap-pull-request) * Deprecate default name of prebuilt branch * Fix test * Fix typo * Fix test
1 parent 2a5469f commit 3838b74

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

.github/workflows/bootstrap-pull-request.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ jobs:
5959
cp -av "$GITHUB_WORKSPACE/bootstrap-pull-request/tests/fixtures/prebuilt/." .
6060
git add .
6161
git commit -m "Add prebuilt branch for e2e-test of ${GITHUB_REF}"
62-
git push origin "HEAD:refs/heads/prebuilt/monorepo-deploy-actions/overlay-${{ github.run_id }}"
62+
git push origin "HEAD:refs/heads/bootstrap-pull-request-e2e-prebuilt-${{ github.run_id }}"
6363
6464
- uses: ./bootstrap-pull-request
6565
with:
6666
overlay: overlay-${{ github.run_id }}
6767
namespace: pr-${{ github.event.number }}
6868
destination-repository: ${{ github.repository }}
69+
prebuilt-branch: bootstrap-pull-request-e2e-prebuilt-${{ github.run_id }}
6970
namespace-manifest: bootstrap-pull-request/tests/fixtures/namespace.yaml
7071
substitute-variables: NAMESPACE=pr-${{ github.event.number }}
7172

@@ -75,6 +76,7 @@ jobs:
7576
overlay: overlay-${{ github.run_id }}
7677
namespace: pr-${{ github.event.number }}
7778
destination-repository: ${{ github.repository }}
79+
prebuilt-branch: bootstrap-pull-request-e2e-prebuilt-${{ github.run_id }}
7880
namespace-manifest: bootstrap-pull-request/tests/fixtures/namespace.yaml
7981
substitute-variables: NAMESPACE=pr-${{ github.event.number }}
8082

@@ -87,4 +89,4 @@ jobs:
8789
continue-on-error: true
8890
if: always()
8991
run: |
90-
git push origin --delete "refs/heads/prebuilt/monorepo-deploy-actions/overlay-${{ github.run_id }}"
92+
git push origin --delete "refs/heads/bootstrap-pull-request-e2e-prebuilt-${{ github.run_id }}"

bootstrap-pull-request/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
overlay: pr
4949
namespace: pr-${{ github.event.number }}
5050
destination-repository: octocat/generated-manifests
51+
prebuilt-branch: prebuilt/source-repository/pr
5152
destination-repository-token: ${{ steps.destination-repository-github-app.outputs.token }}
5253
namespace-manifest: deploy-config/overlays/pr/namespace.yaml
5354
substitute-variables: |
@@ -72,12 +73,6 @@ It creates the following directory structure.
7273
└── generated.yaml
7374
```
7475

75-
It assumes that the below name of prebuilt branch exists in the destination repository.
76-
77-
```
78-
prebuilt/${source-repository}/${overlay}
79-
```
80-
8176
It bootstraps the namespace branch by the following steps:
8277

8378
1. Delete the outdated application manifests

bootstrap-pull-request/action.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ inputs:
1515
destination-repository:
1616
description: Destination repository
1717
required: true
18+
prebuilt-branch:
19+
description: Name of prebuilt branch in the destination repository. This input will be required in the future release.
20+
required: false
1821
destination-repository-token:
1922
description: GitHub token for destination repository
2023
required: true

bootstrap-pull-request/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const main = async (): Promise<void> => {
77
namespace: core.getInput('namespace', { required: true }),
88
sourceRepository: core.getInput('source-repository', { required: true }),
99
destinationRepository: core.getInput('destination-repository', { required: true }),
10+
prebuiltBranch: core.getInput('prebuilt-branch', { required: false }) || undefined,
1011
destinationRepositoryToken: core.getInput('destination-repository-token', { required: true }),
1112
namespaceManifest: core.getInput('namespace-manifest') || undefined,
1213
substituteVariables: core.getMultilineInput('substitute-variables'),

bootstrap-pull-request/src/run.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Inputs = {
1010
namespace: string
1111
sourceRepository: string
1212
destinationRepository: string
13+
prebuiltBranch: string | undefined
1314
destinationRepositoryToken: string
1415
namespaceManifest: string | undefined
1516
substituteVariables: string[]
@@ -32,7 +33,11 @@ export const run = async (inputs: Inputs): Promise<Outputs> => {
3233

3334
const bootstrapNamespace = async (inputs: Inputs): Promise<Outputs | Error> => {
3435
const [, sourceRepositoryName] = inputs.sourceRepository.split('/')
35-
const prebuiltBranch = `prebuilt/${sourceRepositoryName}/${inputs.overlay}`
36+
// TODO: prebuiltBranch input will be required in the future release.
37+
if (inputs.prebuiltBranch === undefined) {
38+
core.warning('prebuilt-branch input will be required in the future release.')
39+
}
40+
const prebuiltBranch = inputs.prebuiltBranch ?? `prebuilt/${sourceRepositoryName}/${inputs.overlay}`
3641

3742
const prebuiltDirectory = await checkoutPrebuiltBranch(inputs, prebuiltBranch)
3843
const namespaceDirectory = await checkoutNamespaceBranch(inputs)

git-push-service/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,19 @@ To push a manifest as a prebuilt manifest:
9090
manifests: ${{ steps.kustomize.outputs.directory }}/**
9191
overlay: pr
9292
service: foo
93-
destination-branch: prebuilt/REPOSITORY/pr
93+
destination-branch: prebuilt/source-repository/pr
9494
```
9595
9696
It pushes the following file into a destination repository:
9797
9898
```
99-
destination-repository (branch: prebuilt/${project}/${overlay})
99+
destination-repository (branch: prebuilt/source-repository/pr)
100100
└── services
101101
└── ${service}
102102
└── generated.yaml
103103
```
104104

105-
You can build the prebuilt manifest using [git-push-services-from-prebuilt action](../git-push-services-from-prebuilt).
105+
You can build the prebuilt manifest using [bootstrap-pull-request action](../bootstrap-pull-request).
106106

107107
## Options
108108

0 commit comments

Comments
 (0)