Skip to content

Commit

Permalink
First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstein committed Sep 17, 2024
0 parents commit 78a57e6
Show file tree
Hide file tree
Showing 12 changed files with 1,053 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github: [mattstein]
ko_fi: mattstein
buy_me_a_coffee: mattts
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Create Alfred Workflow

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Composer dependencies
uses: php-actions/composer@v6
# Store version number without `v`
- name: Write release version
run: |
TAG=${{ github.ref_name }}
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Build Alfred workflow
id: alfred_builder
uses: com30n/build-alfred-workflow@v1
with:
workflow_dir: .
exclude_patterns: '.git/* .gitignore .github docker_tag Dockerfile-php-build DOCKER_ENV output.log resources/*'
custom_version: "${{ env.VERSION }}"
- name: Create release
id: create_release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ secrets.RELEASE_TOKEN }}
files: ${{ steps.alfred_builder.outputs.workflow_file }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
.DS_Store
vendor/
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 Matt Stein

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.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Cloudflare Alfred Workflow

Launch Cloudflare zone details in a browser.

![Workflow screenshot](resources/screenshot.png)

Custom theme using [Berkeley Mono](https://berkeleygraphics.com/typefaces/berkeley-mono/).

## Installation

Download the `.alfredworkflow` file from the [latest release](https://github.com/mattstein/alfred-cloudflare-workflow/releases) and double-click to install.

## Configuration

You must provide either a Cloudflare API token (recommended) or a global email address and API key.

| Variable | Default | Required? | Note |
| --- | --- | --- | --- |
| `CLOUDFLARE_API_TOKEN` | || Required and recommended. |
| `CLOUDFLARE_EMAIL` | || Required if you don’t create an API token. |
| `CLOUDFLARE_API_KEY` | || Required with the email address if you don’t create an API token. |
| `CACHE_SECONDS` | 30 || Duration for which cached responses will be re-used. |

### Creating an API Token

The token takes slightly more setup, but it’s safer because you can limit its permissions so you don’t have to stress out if it’s ever compromised. (This workflow uses Cloudflare’s first-party PHP SDK and doesn’t do anything shady, but it’s a Good Idea™ to be very careful about storing secrets.)

1. In the Cloudflare web control panel, click the user avatar in the top right and then click **My Profile**.
2. In the sidebar navigation menu, click **API Tokens**.
3. On this “User API Tokens” page, click **Create Token**.
4. Next to “Create Custom Token” at the bottom of the page, click **Get started**.
5. Fill out the fields.
- **Token name** is up to you. I picked “Alfred” because this is no time to be clever.
- **Permissions** should select **Zone**, then **Zone Settings**, and **Read**.
- **Zone Resources** should select **Include** and **All zones** unless you’d prefer to limit it further.
- You can skip **Client IP Address Filtering** and **TTL** unless you’d like to set them.
6. Click **Continue to summary**.
7. Confirm by clicking **Create Token**.
8. Copy the resulting token and add it to the workflow’s `CLOUDFLARE_API_TOKEN` environment variable.

That’s it! This way you don’t need your account email address and global key.

## Usage

Use the Alfred trigger `cf` to automatically list your Cloudflare Zones, which can optionally be filtered if you keep typing.

Press <kbd>return</kbd> to open a browser window with that zone in Cloudflare’s control panel.
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"joetannenbaum/alfred-workflow": "^1.1",
"cloudflare/sdk": "^1.3"
}
}
Loading

0 comments on commit 78a57e6

Please sign in to comment.