diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..2735ea1 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,40 @@ +--- +name-template: "v$RESOLVED_VERSION" +tag-template: "v$RESOLVED_VERSION" +template: | + # Changelog + + $CHANGES + + See details of [all code changes](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release. +categories: + - title: "🚀 Features" + labels: + - "feature" + - "enhancement" + - title: "🐛 Bug Fixes" + labels: + - "fix" + - "bugfix" + - "bug" + - title: "🧰 Maintenance" + labels: + - "infrastructure" + - "automation" + - "documentation" + - title: "🏎 Performance" + label: "performance" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +version-resolver: + major: + labels: + - "type: breaking" + minor: + labels: + - "type: enhancement" + patch: + labels: + - "type: bug" + - "type: maintenance" + - "type: documentation" + default: patch diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml new file mode 100644 index 0000000..4575aaf --- /dev/null +++ b/.github/workflows/draft-release.yml @@ -0,0 +1,14 @@ +name: Draft release +on: + push: + branches: + - main + +jobs: + draft-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bf81b5d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: Release +on: + release: + types: [edited] + workflow_dispatch: + inputs: + TAG_NAME: + description: "Tag name that the major tag will point to" + required: true + +env: + TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} + +permissions: + contents: write + +jobs: + update_tag: + name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes + runs-on: ubuntu-latest + environment: + # Note: this environment is protected + name: Release + steps: + - name: Update the ${{ env.TAG_NAME }} tag + id: update-major-tag + uses: actions/publish-action@v0.1.0 + with: + source-tag: ${{ env.TAG_NAME }} + slack-webhook: ${{ secrets.SLACK_WEBHOOK }} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d684104 --- /dev/null +++ b/LICENSE @@ -0,0 +1,47 @@ +MIT License Copyright (c) 2022 The Astro Technology Company + +Permission is hereby granted, free of +charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice +(including the next paragraph) shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO +EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + +Portions of this code adapted from https://github.com/actions/upload-pages-artifact + +MIT License + +Copyright (c) 2022 GitHub, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..99b82d8 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# Astro Deploy Action + +This action for [Astro](https://github.com/withastro/astro) builds your Astro project for [GitHub Pages](https://pages.github.com/). + +## Usage + +### Inputs + +- `path` - The root location of your Astro project inside the repository. Defaults to `/`. +- `node-version` - The specific version of Node that should be used to build your site. Defaults to `16`. +- `package-manager` - The Node package manager that should be used to install dependencies and build your site. Defaults to `npm`. + +### Example workflow: + +#### Build and Deploy to GitHub Pages + +Create a file at `.github/workflows/deploy.yml` with the following content. + +```yml +name: Deploy + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + workflow_dispatch: + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: withastro/action@v0 + + deploy: + needs: build + runs-on: ubuntu-latest + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..2e3e99d --- /dev/null +++ b/action.yml @@ -0,0 +1,41 @@ +name: "Astro Deploy" +description: "A composite action that prepares your Astro site to be deployed to GitHub Pages" +inputs: + path: + description: "Path of the directory containing your site" + required: true + default: "" + node-version: + description: "The node version to use" + required: true + default: "16" + package-manager: + description: "The package manager that installs, builds and deploys" + required: true + default: "npm" + +runs: + using: composite + steps: + - name: Setup PNPM + if: ${{ inputs.package-manager == 'pnpm' }} + uses: pnpm/action-setup@v2.2.2 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + cache: ${{ inputs.package-manager }} + + - name: Install + shell: "bash" + run: ${{ inputs.package-manager }} install + + - name: Build + shell: "bash" + run: ${{ inputs.package-manager }} run build + + - name: Upload Pages Artifact + uses: actions/upload-pages-artifact@v1 + with: + path: "${{ inputs.path }}dist/"