|
7 | 7 | pull_request: |
8 | 8 | branches: [main] |
9 | 9 |
|
| 10 | +# Only allow one job of this action to be ran at a time |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
10 | 15 | jobs: |
11 | 16 | build-and-validate: |
12 | 17 | runs-on: ubuntu-latest |
|
65 | 70 | run: | |
66 | 71 | go fmt -x ./... |
67 | 72 | git diff --exit-code || { echo 'Go sources need to be formatted. Execute "go fmt -x ./..." locally in the 'generator' folder and commit changes to fix an issue'; exit 1; } |
68 | | - - name: Upload Json schemas |
69 | | - uses: actions/upload-artifact@v2 |
70 | | - with: |
71 | | - name: devfile-json-schema |
72 | | - path: schemas/latest/devfile.json |
73 | | - |
74 | | - publish-next-json-schema: |
75 | | - if: success() && github.event_name == 'push' |
76 | | - runs-on: ubuntu-latest |
77 | | - needs: [build-and-validate] |
78 | | - steps: |
79 | | - - name: Setup Python |
80 | | - uses: actions/setup-python@v4 |
81 | | - with: |
82 | | - python-version: '3.9' |
83 | | - |
84 | | - - name: Checkout devfile docs |
85 | | - uses: actions/checkout@v2 |
86 | | - with: |
87 | | - repository: devfile/devfile-web |
88 | | - persist-credentials: false |
89 | | - path: devfile-web-repo |
90 | | - |
91 | | - - name: Checkout devfile api |
92 | | - uses: actions/checkout@v2 |
93 | | - with: |
94 | | - path: api-repo |
95 | | - |
96 | | - - name: Get the version being published |
97 | | - id: get_version |
98 | | - run: echo ::set-output name=version::$(cat api-repo/schemas/latest/jsonSchemaVersion.txt) |
99 | | - |
100 | | - - name: Publish the new version on devfile-web |
101 | | - run: | |
102 | | - cd devfile-web-repo/ |
103 | | - python devfile-web-repo/python/src/api_workflow/api_workflow.py --version ${{ steps.get_version.outputs.version }} --devfile-schema api-repo/schemas/latest/devfile.json --release |
104 | | -
|
105 | | - - name: Push to the devfile/devfile-web repo |
106 | | - working-directory: devfile-web-repo/ |
107 | | - run: | |
108 | | - # Install dependencies to format the commit |
109 | | - yarn install |
110 | | -
|
111 | | - # Format the commit |
112 | | - yarn nx format:write |
113 | | -
|
114 | | - # Lint the commit |
115 | | - yarn nx affected --target=lint |
116 | | - yarn nx format:check |
117 | | -
|
118 | | - # Don't commit if there are no changes |
119 | | - if [ "$(git status -s)" == "" ]; then |
120 | | - echo "Nothing to commit" |
121 | | - exit 0 |
122 | | - fi |
123 | | -
|
124 | | - lastCommit="$(cd ../api-repo; git log -1 --format=%H)" |
125 | | - lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)" |
126 | | - lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)" |
127 | | -
|
128 | | - git config --global user.email "${lastCommitterEmail}" |
129 | | - git config --global user.name "${lastCommitterName}" |
130 | | -
|
131 | | - git add . |
132 | | - git commit -asm "Update devfile schema based on devfile/api@${lastCommit}" |
133 | | - git push "https://devfile-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web" |
0 commit comments