From c8ec381ac2063831745737d4e38c5bc4b2622a69 Mon Sep 17 00:00:00 2001 From: eq19 Date: Thu, 6 Jul 2023 05:24:51 -0500 Subject: [PATCH] update workflow --- .github/workflows/reserves/codeql.yml | 70 ++++++++++++++++ .github/workflows/reserves/matching.yml | 83 +++++++++++++++++++ .../reserves/test_of_push_and_pull.yml | 37 +++++++++ .../reserves/test_of_validate_package.yml | 29 +++++++ .github/workflows/reserves/update.yml | 34 ++++++++ .github/workflows/reserves/validate_links.yml | 28 +++++++ 6 files changed, 281 insertions(+) create mode 100644 .github/workflows/reserves/codeql.yml create mode 100644 .github/workflows/reserves/matching.yml create mode 100644 .github/workflows/reserves/test_of_push_and_pull.yml create mode 100644 .github/workflows/reserves/test_of_validate_package.yml create mode 100644 .github/workflows/reserves/update.yml create mode 100644 .github/workflows/reserves/validate_links.yml diff --git a/.github/workflows/reserves/codeql.yml b/.github/workflows/reserves/codeql.yml new file mode 100644 index 00000000..0071d200 --- /dev/null +++ b/.github/workflows/reserves/codeql.yml @@ -0,0 +1,70 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '38 3 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript', 'ruby' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/reserves/matching.yml b/.github/workflows/reserves/matching.yml new file mode 100644 index 00000000..940f7a92 --- /dev/null +++ b/.github/workflows/reserves/matching.yml @@ -0,0 +1,83 @@ +name: CI + +on: + push: + branches: [develop] + pull_request: + branches: [develop] + +jobs: + checkout: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.matching.outputs.version }} + steps: + - uses: actions/checkout@main + - uses: rundocs/checkout@master + - name: Match the commit message whether to Release! + run: | + MESSAGE=$(git log -1 --format="%s") + if [[ ${MESSAGE} =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then + echo "::set-output name=version::${MESSAGE:1}" + fi + id: matching + if: ${{ github.event_name == 'push' }} + release: + runs-on: ubuntu-latest + needs: checkout + if: ${{ needs.checkout.outputs.version }} + env: + VERSION: ${{ needs.checkout.outputs.version }} + steps: + - uses: actions/checkout@main + with: + fetch-depth: 0 + - uses: actions/setup-node@main + - uses: actions/setup-ruby@main + + - name: Generate changelog and Auto update version! + run: | + LAST_TAG=$(git describe --tags --abbrev=0) + git log ${LAST_TAG}..HEAD --no-merges --format="- %h %s @%an" > action.changelog.md + sed -i "s/${LAST_TAG:1}/${VERSION}/g" jekyll-rtd-theme.gemspec + sed -i "s/${LAST_TAG:1}/${VERSION}/g" _includes/rest/defaults.liquid + + - name: Prettier check and Build theme assets! + run: | + npm install + npm run format && npm run build + + - name: Save changes! + run: | + git remote set-url origin "https://${GITHUB_ACTOR}:${{ secrets.AUTH_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git add . + git commit -m "💎 v${VERSION}" && git push + + - name: Create release! + uses: actions/create-release@main + with: + release_name: ${{ needs.checkout.outputs.version }} + tag_name: v${{ needs.checkout.outputs.version }} + commitish: ${{ github.ref }} + body_path: action.changelog.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure gem credentials and Build gemspec! + run: | + CONFIG=${HOME}/.gem/credentials + mkdir -p ${HOME}/.gem && touch ${CONFIG} && chmod 0600 ${CONFIG} + echo "---" > ${CONFIG} + echo ":github: Bearer ${GITHUB_TOKEN}" >> ${CONFIG} + echo ":rubygems_api_key: ${RUBYGEMS_AUTH_TOKEN}" >> ${CONFIG} + gem build *.gemspec + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RUBYGEMS_AUTH_TOKEN: ${{ secrets.RUBYGEMS_AUTH_TOKEN }} + + - name: Publish rubygems! + run: | + gem push *.gem + gem push --KEY github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem diff --git a/.github/workflows/reserves/test_of_push_and_pull.yml b/.github/workflows/reserves/test_of_push_and_pull.yml new file mode 100644 index 00000000..4ee1316f --- /dev/null +++ b/.github/workflows/reserves/test_of_push_and_pull.yml @@ -0,0 +1,37 @@ +name: "Tests of push & pull" + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + FILENAME: README.md + +jobs: + tests: + name: 'Validate README.md changes' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Install dependencies + run: python -m pip install -r scripts/requirements.txt + + - name: Validate Markdown format + run: python scripts/validate/format.py ${FILENAME} + + - name: Validate pull request changes + run: scripts/github_pull_request.sh ${{ github.repository }} ${{ github.event.pull_request.number }} ${FILENAME} + if: github.event_name == 'pull_request' + + - name: Checking if push changes are duplicated + run: python scripts/validate/links.py ${FILENAME} --only_duplicate_links_checker + if: github.event_name == 'push' diff --git a/.github/workflows/reserves/test_of_validate_package.yml b/.github/workflows/reserves/test_of_validate_package.yml new file mode 100644 index 00000000..f739df81 --- /dev/null +++ b/.github/workflows/reserves/test_of_validate_package.yml @@ -0,0 +1,29 @@ +name: "Tests of validate package" + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + unittest: + name: 'Run tests of validate package' + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Install dependencies + run: python -m pip install -r scripts/requirements.txt + + - name: Run Unittest + run: | + cd scripts + python -m unittest discover tests/ --verbose diff --git a/.github/workflows/reserves/update.yml b/.github/workflows/reserves/update.yml new file mode 100644 index 00000000..642beb67 --- /dev/null +++ b/.github/workflows/reserves/update.yml @@ -0,0 +1,34 @@ +name: Update dependencies + +on: + schedule: + - cron: "0 0 * * 0" + workflow_dispatch: {} + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - uses: actions/setup-node@v2 + with: + node-version: '14' + cache: 'npm' + + - name: script/update + run: script/update + + - name: script/build + run: script/build + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + commit-message: Update dependencies + title: Update dependencies \ No newline at end of file diff --git a/.github/workflows/reserves/validate_links.yml b/.github/workflows/reserves/validate_links.yml new file mode 100644 index 00000000..33fef088 --- /dev/null +++ b/.github/workflows/reserves/validate_links.yml @@ -0,0 +1,28 @@ +name: "Validate links" + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +env: + FILENAME: README.md + +jobs: + validate_links: + name: 'Check all links are working' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Install dependencies + run: python -m pip install -r scripts/requirements.txt + + - name: Validate all links from README.md + run: python scripts/validate/links.py ${FILENAME}