Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Convert to GitHub Action #43

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,10 @@ jobs:
runs-on: ubuntu-latest
name: sync
steps:
- name: Checkout repo 🛎
uses: actions/checkout@v4
- uses: acm-uic/calsync@main
with:
ref: main

- name: Setup Deno 🔧
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Run sync 🔁
run: deno run --allow-net --allow-env --allow-read ./mod.ts
env:
DISCORD_EVENTS_SYNC_DISCORD_GUILD_ID: ${{ secrets.DISCORD_EVENTS_SYNC_DISCORD_GUILD_ID }}
DISCORD_EVENTS_SYNC_DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_EVENTS_SYNC_DISCORD_BOT_TOKEN }}
DISCORD_EVENTS_SYNC_DISCORD_APPLICATION_ID: ${{ secrets.DISCORD_EVENTS_SYNC_DISCORD_APPLICATION_ID }}
DISCORD_EVENTS_SYNC_GOOGLE_CALENDAR_CALENDAR_ID: ${{ secrets.DISCORD_EVENTS_SYNC_GOOGLE_CALENDAR_CALENDAR_ID }}
DISCORD_EVENTS_SYNC_GOOGLE_CALENDAR_API_KEY: ${{ secrets.DISCORD_EVENTS_SYNC_GOOGLE_CALENDAR_API_KEY }}
discord-guild-id: ${{ secrets.DISCORD_EVENTS_SYNC_DISCORD_GUILD_ID }}
discord-bot-token: ${{ secrets.DISCORD_EVENTS_SYNC_DISCORD_BOT_TOKEN }}
discord-application-id: ${{ secrets.DISCORD_EVENTS_SYNC_DISCORD_APPLICATION_ID }}
google-calendar-id: ${{ secrets.DISCORD_EVENTS_SYNC_GOOGLE_CALENDAR_CALENDAR_ID }}
google-api-key: ${{ secrets.DISCORD_EVENTS_SYNC_GOOGLE_CALENDAR_API_KEY }}
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,33 @@

🔁 Sync Google Calendar events to Discord Scheduled Events.

🤖 Designed to run as a scheduled job in GitHub Actions.
🤖 Designed to run as a scheduled job in GitHub Actions as a GitHub Action.

## Getting Started

```yml
# .github/workflows/calsync.yml
name: calsync

on:
schedule:
- cron: '0 * * * *' # hourly
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
name: 🔁 Sync Events
steps:
- uses: acm-uic/calsync@main
with:
discord-guild-id: ${{ secrets.DISCORD_GUILD_ID }}
discord-bot-token: ${{ secrets.DISCORD_BOT_TOKEN }} # needs "Read Messages/View Channels", "Manage Events" permissions
discord-application-id: ${{ secrets.DISCORD_APPLICATION_ID }}
google-calendar-id: ${{ secrets.GOOGLE_CALENDAR_CALENDAR_ID }}
google-api-key: ${{ secrets.GOOGLE_CALENDAR_API_KEY }}

```

## How does it work?

Expand All @@ -21,4 +47,4 @@ variables or in `.env.` file in the root of the repository.

## Discord bot permissions

The Discord bot needs permissions to view channels, and to manage events.
The Discord bot needs "Read Messages/View Channels", "Manage Events" permissions.
30 changes: 30 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'calsync'
inputs:
discord-guild-id:
required: true
discord-bot-token:
required: true
discord-application-id:
required: true
google-calendar-id:
required: true
google-api-key:
required: true
runs:
using: "composite"
steps:
- name: Setup Deno 🔧
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Run sync 🔁
shell: bash
working-directory: ${{ github.action_path }}
run: deno run --allow-net --allow-env --allow-read ./mod.ts
env:
DISCORD_EVENTS_SYNC_DISCORD_GUILD_ID: ${{ inputs.discord-guild-id }}
DISCORD_EVENTS_SYNC_DISCORD_BOT_TOKEN: ${{ inputs.discord-bot-token }}
DISCORD_EVENTS_SYNC_DISCORD_APPLICATION_ID: ${{ inputs.discord-application-id }}
DISCORD_EVENTS_SYNC_GOOGLE_CALENDAR_CALENDAR_ID: ${{ inputs.google-calendar-id }}
DISCORD_EVENTS_SYNC_GOOGLE_CALENDAR_API_KEY: ${{ inputs.google-api-key }}