diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index a2e1802f..a105ac56 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -github: devlooped \ No newline at end of file +github: devlooped diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 00000000..323a0f3a --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,58 @@ +name: pages +on: + workflow_dispatch: + push: + branches: + - main + - pages + +env: + PAGES_ORGANIZATION: ${{ secrets.PAGES_ORGANIZATION }} + PAGES_REPOSITORY: ${{ secrets.PAGES_REPOSITORY }} + +jobs: + gh-pages: + runs-on: ubuntu-latest + steps: + - name: 🤘 checkout + uses: actions/checkout@v2 + + - name: ⚙ jekyll + run: | + sudo gem install bundler + bundle install + + - name: 🖉 default env + env: + PAGES_ORGANIZATION: ${{ secrets.PAGES_ORGANIZATION }} + PAGES_REPOSITORY: ${{ secrets.PAGES_REPOSITORY }} + run: | + echo "PAGES_ORGANIZATION=${PAGES_ORGANIZATION}" >> $GITHUB_ENV + echo "PAGES_REPOSITORY=${PAGES_REPOSITORY}" >> $GITHUB_ENV + + - name: 🖉 default repo + if: env.PAGES_REPOSITORY == '' + run: echo "PAGES_REPOSITORY=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV + + - name: 🙏 build + run: bundle exec jekyll build -b ${{ env.PAGES_REPOSITORY }} + env: + JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: ✓ commit + run: | + cd _site + git init + git add -A + git config --local user.email "bot@devlooped.com" + git config --local user.name "bot@devlooped.com" + git commit -m "Publish pages from ${GITHUB_REPOSITORY}@${GITHUB_SHA:0:9}" + + - name: 🚀 push + uses: ad-m/github-push-action@v0.6.0 + with: + github_token: ${{ secrets.PAGES_ACCESS_TOKEN }} + repository: ${{ env.PAGES_ORGANIZATION }}/${{ env.PAGES_REPOSITORY }} + branch: gh-pages + force: true + directory: ./_site \ No newline at end of file diff --git a/.github/workflows/sponsors.ps1 b/.github/workflows/sponsors.ps1 new file mode 100644 index 00000000..791fd7cc --- /dev/null +++ b/.github/workflows/sponsors.ps1 @@ -0,0 +1,59 @@ +$event = Get-Content -Path $env:GITHUB_EVENT_PATH | ConvertFrom-Json +$author = $event.issue ? $event.issue.user.node_id : $event.pull_request.user.node_id + +if ($author -eq $null) { + throw 'No user id found' +} + +gh auth status + +echo "Looking up sponsorship from $env:GITHUB_ACTOR ..." + +$query = gh api graphql --paginate -f owner='devlooped' -f query=' +query($owner: String!, $endCursor: String) { + organization (login: $owner) { + sponsorshipsAsMaintainer (first: 100, after: $endCursor) { + nodes { + sponsorEntity { + ... on Organization { id, name } + ... on User { id, name } + } + tier { monthlyPriceInDollars } + } + pageInfo { + hasNextPage + endCursor + } + } + } +} +' + +$amount = + $query | + ConvertFrom-Json | + select @{ Name='nodes'; Expression={$_.data.organization.sponsorshipsAsMaintainer.nodes}} | + select -ExpandProperty nodes | + where { $_.sponsorEntity.id -eq $author } | + select -ExpandProperty tier | + select -ExpandProperty monthlyPriceInDollars + +if ($null -eq $amount) { + echo "Author is not a sponsor! Nothing left to do." + return +} + +echo "Author is a sponsor!" + +$headers = @{ 'Accept'='application/vnd.github.v3+json;charset=utf-8'; 'Authorization' = "bearer $env:GH_TOKEN" } + +# Try creating the labels, ignore errors (i.e. already created) +iwr -Body '{ "name":"sponsor :purple_heart:", "color":"ea4aaa", "description":"sponsor" }' "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/labels" -Method Post -Headers $headers -SkipHttpErrorCheck -UseBasicParsing | select -ExpandProperty StatusCode +iwr -Body '{ "name":"sponsor :yellow_heart:", "color":"ea4aaa", "description":"sponsor++" }' "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/labels" -Method Post -Headers $headers -SkipHttpErrorCheck -UseBasicParsing | select -ExpandProperty StatusCode + +$number = $event.issue ? $event.issue.number : $event.pull_request.number +$labels = $amount -ge 100 ? '{"labels":["sponsor :yellow_heart:"]}' : '{"labels":["sponsor :purple_heart:"]}' + +iwr -Body $labels "$env:GITHUB_API_URL/repos/$env:GITHUB_REPOSITORY/issues/$number/labels" -Method Post -Headers $headers -SkipHttpErrorCheck -UseBasicParsing | select -ExpandProperty StatusCode + +echo 'Label applied' diff --git a/.github/workflows/sponsors.yml b/.github/workflows/sponsors.yml new file mode 100644 index 00000000..1a3b1199 --- /dev/null +++ b/.github/workflows/sponsors.yml @@ -0,0 +1,23 @@ +# Runs on new issues/PRs and applies sponsor labels + +name: sponsors +on: + issues: + types: [opened] + +jobs: + sponsors: + runs-on: windows-latest + steps: + - name: 🤘 checkout + uses: actions/checkout@v2 + + - name: 🔽 gh + run: | + iwr -useb get.scoop.sh | iex + scoop install gh + + - name: 💛 sponsors + run: ./.github/workflows/sponsors.ps1 + env: + GH_TOKEN: ${{ secrets.DEVLOOPED_TOKEN }} diff --git a/.netconfig b/.netconfig index 5a9ff8b8..1372f154 100644 --- a/.netconfig +++ b/.netconfig @@ -1,5 +1,6 @@ [file] url = https://github.com/devlooped/oss + url = https://github.com/devlooped/.github [file "readme.md"] url = https://github.com/devlooped/oss/blob/main/readme.md skip @@ -21,10 +22,10 @@ weak sha = 0683ee777d7d878d4bf013d7deea352685135a05 [file ".github/FUNDING.yml"] - url = https://github.com/devlooped/oss/blob/main/.github/FUNDING.yml - etag = f4d02805592d1f86c29acc9da3a40e817fb3611d6ff0f6409f547137f38f65df + url = https://github.com/devlooped/.github/blob/main/.github/FUNDING.yml + etag = a944c728facd033bbdfb4ff8d0ef10d0b3a457c277dc499458df0ffc7e6409da weak - sha = 4c91539ec08a3f9c14ff1e8c6a7c4ae88795f5f1 + sha = 39f4c591716ff50dd035d2fade35e5822489ab7f [file ".github/ISSUE_TEMPLATE/bug.md"] url = https://github.com/devlooped/oss/blob/main/.github/ISSUE_TEMPLATE/bug.md etag = 026852ba1f1921f3a043bb5e09cd7a2c3d9a33ec51f48e524dc3a2ab72de3141 @@ -155,3 +156,23 @@ sha = 7d0ccab53c166b87b971040f25de06570821f8ac etag = 0ef58051c4db505e16b39954b27ab9e7a903647998b959e0924634d5f01824dd weak +[file ".github/workflows/pages.yml"] + url = https://github.com/devlooped/.github/blob/main/.github/workflows/pages.yml + sha = e8f3774884afda36ac177c4193929d24d7901de9 + etag = 42fdc888e07b492cccc6fd29972bd9ea6f13691a3fdf057e07f3f8eec9330b7a + weak +[file ".github/workflows/sponsors.ps1"] + url = https://github.com/devlooped/.github/blob/main/.github/workflows/sponsors.ps1 + sha = 11f5c27cfdb304436ef0b7ee27ff333cda31ef65 + etag = 57a303125f3367b68ad0700d89ff4ba57cb29b33b303903488c9c8638d0bf735 + weak +[file ".github/workflows/sponsors.yml"] + url = https://github.com/devlooped/.github/blob/main/.github/workflows/sponsors.yml + sha = 514760df24bd906b9e5d3a56deac0d18cba59a6d + etag = 0236ed96c1d11f69b26ac0e039e74107df5731574236e2de2a83152fee5df0a6 + weak +[file "Gemfile"] + url = https://github.com/devlooped/.github/blob/main/Gemfile + sha = f2dc1370469bec1b2d32d82faf659b050cdc7e2a + etag = d45832acd078778ffebf260000f6d25172a131f51684744d7e982da2a47170ce + weak diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..025f43f7 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'github-pages', '~> 209', group: :jekyll_plugins \ No newline at end of file