Skip to content

Commit

Permalink
revise actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jmesrje committed Sep 13, 2024
1 parent 25fd34a commit f9afdc0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: ci
name: ci
on:
release:
types: [published]
push:
branches:
- master
- main
permissions:
contents: write
jobs:
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/event.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Event

on:
pull_request:
types: [opened]
issues:
types: [opened]

Expand All @@ -22,12 +20,7 @@ jobs:
WEBHOOK_URL: ${{ secrets.EVENT_WEBHOOK_URL }}
run: |
PROJECT="${{ github.repository }}"
if [ "${{ github.event_name }}" == "issues" ]; then
EVENT_URL="${{ github.event.issue.html_url }}"
EVENT_TITLE="${{ github.event.issue.title }}"
elif [ "${{ github.event_name }}" == "pull_request" ]; then
EVENT_URL="${{ github.event.pull_request.html_url }}"
EVENT_TITLE="${{ github.event.pull_request.title }}"
fi
EVENT_URL="${{ github.event.issue.html_url }}"
EVENT_TITLE="${{ github.event.issue.title }}"
lune run .lune/discord.luau "$WEBHOOK_URL" "event" "$PROJECT" "$EVENT_TITLE" "$EVENT_URL"
lune run .lune/discord.luau "$WEBHOOK_URL" "event" "$PROJECT" "$EVENT_TITLE" "$EVENT_URL"
13 changes: 10 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ jobs:
- name: Install Wally dependencies
run: wally install

- name: Generate sourcemap
run: argon sourcemap standalone.project.json --output sourcemap.json

- name: Generate package types
run: wally-package-types --sourcemap sourcemap.json Packages

- name: Format code
run: stylua src/

Expand All @@ -74,6 +80,7 @@ jobs:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
prerelease: ${{ contains(github.ref_name, 'rc') }}
generate_release_notes: true
body: |
## Changelog
${{ needs.bump.outputs.release-body }}
Expand All @@ -83,7 +90,7 @@ jobs:
publish-package:
name: Publish Package
runs-on: ubuntu-latest
needs: publish-build
needs: bump
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -105,7 +112,7 @@ jobs:
publish-announcement:
name: Publish Announcement
runs-on: ubuntu-latest
needs: publish-package
needs: [publish-package, publish-build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -119,4 +126,4 @@ jobs:
run: |
PROJECT="${{ github.repository }}"
VERSION="${{ github.ref_name }}"
lune run .lune/discord.luau "$WEBHOOK_URL" "announcement" "$PROJECT" "$VERSION"
lune run .lune/discord.luau "$WEBHOOK_URL" "announcement" "$PROJECT" "$VERSION"
17 changes: 9 additions & 8 deletions .lune/discord.luau
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ local net = require("@lune/net")
local process = require("@lune/process")

local projectRole = "1205321049957339228"
local projectMainterRole = "1265887191922511953"

local webhook_url = process.args[1]
local type = process.args[2]
local project = process.args[3]

local projectName = string.split(project, "/")[2]
local formattedProjectName = string.gsub(projectName, "^%a", function(match)
return string.upper(match)
end)

if type == "announcement" then
local tag = process.args[4]
Expand All @@ -21,9 +23,9 @@ if type == "announcement" then
content = if noPing == true then nil else `<@&{projectRole}>`,
embeds = {
{
title = `Release {tag} · lumin-dev/{projectName}`,
description = `Release notification for the latest version of {projectName}`,
url = `https://github.com/lumin-dev/{projectName}/releases/tag/{tag}`,
title = `Release {tag} · {formattedProjectName}`,
description = `Release notification for the latest version of {formattedProjectName}`,
url = `https://github.com/luminlabsdev/{projectName}/releases/tag/{tag}`,
color = 7506646,
author = {
name = "GitHub",
Expand All @@ -43,18 +45,17 @@ elseif type == "event" then
method = "POST",
headers = { ["Content-Type"] = "application/json" },
body = net.jsonEncode({
content = `<@&{projectMainterRole}>`,
embeds = {
{
title = title,
description = `[View issue/pull request]({url})`,
description = `[View issue]({url})`,
color = 7506646,
},
},
thread_name = `{projectName} - {title}`,
thread_name = `{formattedProjectName} - {title}`,
}),
})
if not response.ok then
error(`{response.statusCode}:{response.statusMessage}`)
end
end
end

0 comments on commit f9afdc0

Please sign in to comment.