Skip to content

Commit

Permalink
Setup Common Config
Browse files Browse the repository at this point in the history
  • Loading branch information
doomspork committed Oct 30, 2023
1 parent fb8bf3a commit a5afa24
Show file tree
Hide file tree
Showing 16 changed files with 847 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: CI

on:
pull_request:
types:
- opened
- reopened
- synchronize
push:
branches:
- main

jobs:
Test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
repository:
- ua_parser

steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: true
repository: ${{ format('beam-community/{0}', matrix.repository) }}
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Sync
uses: stordco/actions-sync@v1
with:
pr-enabled: false
sync-auth: doomspork:${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
sync-repository: github.com/beam-community/common-config.git
sync-tree: ${{ github.event.pull_request.head.sha || 'main' }}

- name: Clean
run: |
rm -rf _build
rm -rf .git
rm -rf deps
rm -rf node_modules
- name: Archive
uses: actions/upload-artifact@v3
with:
name: Test ${{ matrix.repository }}
path: ${{ github.workspace }}/**/*
retention-days: 1
31 changes: 31 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: PR

on:
pull_request:
types:
- edited
- opened
- reopened
- synchronize

jobs:
title:
name: Check Title
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Check
uses: stordco/[email protected]
with:
regex: '^(feat!|fix!|fix|feat|chore|(fix|feat|chore)\(\w.*\)):\s(\[\w{1,8}-\d{1,8}\]|.*).*'
hint: |
You can pass the following formats:
fix: [123] some title of the PR
fix(scope): [123] some title of the PR
feat: [1234] some title of the PR
chore: update some action
47 changes: 47 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Publish

on:
release:
types:
- released
- prereleased
workflow_dispatch: {}

permissions:
contents: read
id-token: write
packages: write

jobs:
Sync:
runs-on: ubuntu-latest

steps:
- name: Sync Repositories
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
script: |
const { data } = await github.rest.search.code({
q: 'Common Config org:beam-community path:.github/workflows/',
per_page: 100,
})
const repositories = data.items
.map((i) => i.repository)
.filter((repo, index, list) => {
return list.findIndex((r) => r.id === repo.id) === index;
});
core.info(`Found ${repositories.length} repositories`);
for (const repository of repositories) {
core.info(`Dispatching workflow for ${repository.full_name}`);
await github.rest.repos.createDispatchEvent({
owner: repository.owner.login,
repo: repository.name,
event_type: 'common-config'
});
}
54 changes: 54 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: Release

on:
push:
branches:
- main

jobs:
Please:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- id: release
name: Release
uses: google-github-actions/release-please-action@v3
with:
command: manifest
config-file: .release-please-config.json
manifest-file: .release-please-manifest.json
release-type: simple
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}

- if: ${{ steps.release.outputs.release_created }}
name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ steps.release.outputs.tag_name }}
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
persist-credentials: true

- if: ${{ steps.release.outputs.release_created }}
name: Tag
run: |
git config user.name doomspork
git config user.email [email protected]
git tag -d latest || true
git tag -d v${{ steps.release.outputs.major }} || true
git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git push origin :latest || true
git push origin :v${{ steps.release.outputs.major }} || true
git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git tag -a latest -m "chore(main): release latest"
git tag -a v${{ steps.release.outputs.major }} -m "chore(main): release ${{ steps.release.outputs.major }}"
git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "chore(main): release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}"
git push origin latest
git push origin v${{ steps.release.outputs.major }}
git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}
84 changes: 84 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Created by https://www.toptal.com/developers/gitignore/api/vim,macos,mdbook,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,macos,mdbook,visualstudiocode

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### MdBook ###
book


### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/vim,macos,mdbook,visualstudiocode

test/ci/*
!test/ci/.gitkeep
38 changes: 38 additions & 0 deletions .release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"changelog-sections": [
{
"type": "feat",
"section": "Features",
"hidden": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false
},
{
"type": "chore",
"section": "Miscellaneous",
"hidden": false
}
],
"draft": false,
"draft-pull-request": false,
"packages": {
".": {
"extra-files": [
"README.md"
],
"release-type": "simple"
}
},
"plugins": [
{
"type": "sentence-case"
}
],
"prerelease": false,
"pull-request-header": "An automated release has been created for you.",
"separate-pull-requests": true
}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "1.0.0"
}
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# Common Config

This repository contains shared code for all of our Elixir repositories. This includes configuration files for credo, dialyzer, formatting, and github actions. It syncs all files to repositories on a file change to this repository.

<!-- {x-release-please-start-version} -->

Currently at version `1.0.0`

<!-- {x-release-please-end} -->

## Directories

- `scripts` contains javascript and elixir scripts that are ran on each repository. These could be as simple as copying a file to the repository, or as advanced as changing the `mix.exs` AST to update dependencies.

- `templates` contains files that are copied or templated to the repository.
Loading

0 comments on commit a5afa24

Please sign in to comment.