Update deprecated github actions to latest version (#1231) #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Devfile Schema | |
# Triggers the workflow on push events but only for the main branch | |
on: | |
push: | |
branches: [main] | |
# Only allow one job of this action to be ran at a time | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
publish-json-schema: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Checkout devfile/devfile-web | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
with: | |
repository: devfile/devfile-web | |
persist-credentials: false | |
path: devfile-web-repo | |
- name: Checkout devfile api | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
with: | |
path: api-repo | |
- name: Get the version being published | |
id: get_version | |
run: echo ::set-output name=version::$(cat api-repo/schemas/latest/jsonSchemaVersion.txt) | |
- name: Publish the new version on devfile-web | |
working-directory: devfile-web-repo/ | |
run: | | |
python ./python/src/api_workflow/api_workflow.py --version ${{ steps.get_version.outputs.version }} --devfile-schema ../api-repo/schemas/latest/devfile.json | |
- name: Push to the devfile/devfile-web repo | |
working-directory: devfile-web-repo/ | |
run: | | |
# Install dependencies to format the commit | |
yarn install | |
# Format the commit | |
yarn nx format:write | |
# Lint the commit | |
yarn nx affected --target=lint | |
yarn nx format:check | |
# Don't commit if there are no changes | |
if [ "$(git status -s)" == "" ]; then | |
echo "Nothing to commit" | |
exit 0 | |
fi | |
lastCommit="$(cd ../api-repo; git log -1 --format=%H)" | |
lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)" | |
lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)" | |
git config --global user.email "${lastCommitterEmail}" | |
git config --global user.name "${lastCommitterName}" | |
git add . | |
git commit -asm "Update devfile schema based on devfile/api@${lastCommit}" | |
git push "https://devfile-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web" |