forked from vmware-tanzu/community-edition
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (107 loc) · 3.8 KB
/
package-generate-repository.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Package - Generate Package Repository
on:
push:
branches:
- main
- release-*
tags-ignore:
- "**"
paths:
- addons/packages/**/*/package.yaml
- addons/packages/**/*/metadata.yaml
- addons/repos/main.yaml
jobs:
check:
outputs:
status: ${{ steps.early.outputs.status }}
runs-on: ubuntu-latest
if: github.repository == 'vmware-tanzu/community-edition'
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: "1.17"
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Get diff
id: diffs
run: |
echo "::set-output name=diffs::$(git --no-pager diff --name-only HEAD^ HEAD | tr '\n' ',' | sed 's/\(.*\),/\1 /')"
- name: Echo Change Set
env:
CHANGESET: ${{ steps.diffs.outputs.diffs }}
run: |
echo "Change Set: ${CHANGESET}"
- id: early
shell: bash
name: Early exit
run:
echo "::set-output name=status::$(./hack/workflows/gen-pkgr/check.sh ${{ steps.diffs.outputs.diffs }})"
- id: s2
shell: bash
if: steps.early.outputs.status == 'donotgenerate'
run: |
echo "Do not generate package repository"
- id: s3
shell: bash
if: steps.early.outputs.status == 'generate'
run: |
echo "Generate package repository"
generate-package-repository:
name: Generate Package Repository
runs-on: ubuntu-latest
needs: check
if: github.repository == 'vmware-tanzu/community-edition' && needs.check.outputs.status == 'generate'
steps:
- name: Echo Output Status
run: |
echo "output status: ${{ needs.check.outputs.status }}"
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: "1.17"
id: go
- name: Config credentials
env:
GITHUB_TOKEN: ${{ secrets.GH_PACKAGING_ACCESS_TOKEN }}
run: |
git config --global pull.rebase true
git config --global url."https://git:$GITHUB_TOKEN@github.com".insteadOf "https://github.com"
git config --global user.name github-actions
git config --global user.email github-actions@github.com
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Install Carvel Tools
uses: vmware-tanzu/carvel-setup-action@v1
- name: Check the versions of Carvel tools
run: |
imgpkg version && kbld version && vendir version && ytt version
- name: Login to Harbor with Docker
uses: docker/login-action@v2
with:
registry: projects-stg.registry.vmware.com
username: ${{ secrets.HARBOR_STAGING_USERNAME }}
password: ${{ secrets.HARBOR_STAGING_PASSWORD }}
- name: Generate the Package Repository
id: gen-pkgr
run: |
echo "::set-output name=repo-url::$(make --no-print-directory generate-package-repo CHANNEL=main TAG=$(git rev-parse --short "$GITHUB_SHA") REGISTRY_URL=projects-stg.registry.vmware.com/tce)"
- name: Echo Step
id: echo-step
env:
REPO_URL: ${{steps.gen-pkgr.outputs.repo-url}}
run: |
echo "The REPO_URL is ${REPO_URL}"
- name: Update Pull Request
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'This Pull Request contained a change that generates a new package repository. The repository is available at URL:\n`${{steps.gen-pkgr.outputs.repo-url}}`'
})