From 5b5d052025b237e9ab337ad0f77a521710cfba9c Mon Sep 17 00:00:00 2001 From: Mark Bainter Date: Wed, 22 Nov 2023 10:10:27 -0600 Subject: [PATCH] ci: seutp github actions --- .github/CODEOWNERS | 1 + .github/dependabot.yml | 11 +++++++ .github/workflows/check-pr.yml | 54 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 37 +++++++++++++++++++++++ .github/workflows/tests.yml | 40 +++++++++++++++++++++++++ 5 files changed, 143 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/check-pr.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..0e80780 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +/.github @mbainter diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..030647f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + time: "10:00" + timezone: "America/Chicago" + commit-message: + prefix: "chore: " + include: "scope" diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml new file mode 100644 index 0000000..c7b2ac3 --- /dev/null +++ b/.github/workflows/check-pr.yml @@ -0,0 +1,54 @@ +name: 'Validate PR title' + +permissions: + pull-requests: read + checks: read + statuses: write + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + # Please look up the latest version from + # https://github.com/amannn/action-semantic-pull-request/releases + - uses: amannn/action-semantic-pull-request@v5.4.0 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + # Configure which types are allowed. + # Default: https://github.com/commitizen/conventional-commit-types + types: | + fix + feat + docs + ci + chore + style + refactor + test + requireScope: false + subjectPattern: ^[A-Z].+$ + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + starts with an uppercase character. + # For work-in-progress PRs you can typically use draft pull requests + # from Github. However, private repositories on the free plan don't have + # this option and therefore this action allows you to opt-in to using the + # special "[WIP]" prefix to indicate this state. This will avoid the + # validation of the PR title and the pull request checks remain pending. + # Note that a second check will be reported if this is enabled. + wip: true + # When using "Squash and merge" on a PR with only one commit, GitHub + # will suggest using that commit message instead of the PR title for the + # merge commit, and it's easy to commit this by mistake. Enable this option + # to also validate the commit message for one commit PRs. + validateSingleCommit: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2f6bfcc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Build and release +on: + # Create the tests pass... + workflow_run: + workflows: + - Run tests + branches: + - main + types: + - completed + workflow_dispatch: + +env: + DATAPACK_BASENAME: "bmc3-mining-dimension" + +jobs: + release: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Run PackSquash + uses: ComunidadAylas/PackSquash-action@v4 + with: + artifact_name: "$DATAPACK_BASENAME" + packsquash_version: latest + options: | + pack-directory = '.' + output_file_path = '/tmp/${DATAPACK_BASENAME}.zip' + - name: Tag and create release + uses: softprops/action-gh-release@v1 + with: + tag_name: "v${{ github.run_number }}" + files: "/tmp/${DATAPACK_BASENAME}.zip" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..c0e3821 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,40 @@ +name: Run tests +on: + pull_request: + push: + branches: + - main + paths: + - data/** +jobs: + build-main: + runs-on: ubuntu-latest + steps: + # Clones repository so it has access to the files + - name: Checkout repo + uses: actions/checkout@v4 + - name: Determine the pull-request id + id: pr + run: echo "::set-output name=pr_number::$(gh pr view --json number -q .number || echo "")" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Checks mcfunction files for errors + - name: Check commands + uses: mcbeet/check-commands@v1 + with: + source: . + minecraft: 1.19 + # Checks JSON for errors + - name: Check JSON + uses: ocular-d/json-linter@0.0.2 + # Uploads an artifact that you can download and use in your Minecraft world + - name: Compile and upload + uses: actions/upload-artifact@v3 + with: + name: bmc3-mining-dimension-pr${{steps.pr.outputs.pr_number}} + path: | + data/ + pack.mcmeta + pack.png + # Errors if files aren't found + if-no-files-found: error