Skip to content

Commit 9fdc248

Browse files
committed
Setup git
1 parent 0549813 commit 9fdc248

File tree

7 files changed

+347
-0
lines changed

7 files changed

+347
-0
lines changed

.devcontainer/.gh_alias.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
workon: '!gh tt workon "$@"'
2+
wrapup: '!gh tt wrapup "$@"'
3+
deliver: '!gh tt deliver "$@"'
4+
responsibles: '!gh tt responsibles "$@"'
5+
semver: '!gh tt semver "$@"'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Prep-runner
2+
description: Sets the GitHub workflow to do what we need
3+
4+
inputs:
5+
verify:
6+
description: Script to run to verify the environment is set up correctly. If not provided, no verification will be done.
7+
required: false
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Set up Node.js
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: "20"
16+
17+
# Install npm packages required by .githooks/pre-commit
18+
- name: Install linting and checker tools
19+
shell: bash
20+
run: npm install -g cspell markdownlint-cli2 @cspell/dict-da-dk prettier
21+
22+
- name: Verify environment
23+
if: ${{ inputs.verify }}
24+
shell: bash
25+
run: ${{ inputs.verify }}
26+

.github/workflows/ready.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Ready
2+
# This workflow is triggered by 'ready' branches
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- "ready/**"
9+
10+
jobs:
11+
trunk-worthy:
12+
name: Check trunk worthyness
13+
runs-on: ubuntu-latest
14+
env:
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
permissions:
17+
contents: read
18+
statuses: write
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v6
23+
24+
- name: Mark pending
25+
run: ./.scripts/trunk-worthy mark-pending
26+
27+
- name: Set up runner environment
28+
uses: ./.github/actions/prep-runner
29+
with:
30+
verify: ./.scripts/trunk-worthy
31+
32+
# At this point we only duplicated the wrapup flow.
33+
# Add all additional jobs you want to run on the ready branch before the merge-to-trunk job
34+
# and make merge-to-trunk depend on them (like it depends on trunk-worthy) to ensure they run before the merge.
35+
36+
37+
merge-to-trunk:
38+
name: Merge to trunk
39+
runs-on: ubuntu-latest
40+
needs: trunk-worthy
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
permissions:
44+
pull-requests: write
45+
issues: write
46+
contents: write
47+
48+
steps:
49+
50+
# Not sue what goes on here? Whre did the secret come from?
51+
# check *./docs/ready-pusher.md' for more details on how to set up and use this workflow
52+
- uses: actions/checkout@v6
53+
with:
54+
fetch-depth: 0 # Fetch full history to ensure we can merge and push
55+
token: ${{ secrets.READY_PUSHER }} # PAT with content:write (can not use secrets.GITHUB_TOKEN as it is a special case, it does not trigger other workflows on push)
56+
57+
- uses: devx-cafe/takt-actions/ready-to-trunk@v1
58+
# with: #Uncomment if you want to override any of the default inputs
59+
# target_branch: #default is main
60+
# user_name: #default is "Ready Pusher Bot"
61+
# user_email: #default is "ready-pusher@${{ github.repository_owner }}.github.com"
62+
# delete_dev_branch: false # default is true
63+
# delete_ready_branch: false # default is true
64+
# close_pr: false # default is true
65+
# close_issue: false # default is true

.github/workflows/release.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+' # Matches Core SemVer versions - without a prefix: 0.9.0, 1.2.3
7+
- '[a-zA-Z]+[0-9]+.[0-9]+.[0-9]+' # Matches Core SemVer versions - with a prefix: v1.0.0, ver1.0.0, RC1.0.0
8+
- '[0-9]+.[0-9]+.[0-9]+*' # Matches Build and Prerelease SemVer versions - without a prefix: 0.9.0+1.03ed4d1, 0.9.0-alpha1, 0.9.0-alpha1+1.03ed4d1
9+
- '[a-zA-Z]+[0-9]+.[0-9]+.[0-9]+*' # Matches Build and Prerelease SemVer versions - with a prefix: v0.9.0+1.03ed4d1, ver0.9.0-alpha1, RC0.9.0-alpha1+1.03ed4d1
10+
11+
workflow_dispatch:
12+
inputs:
13+
tag:
14+
description: "Tag to release (e.g., v1.0.0 or 1.0.0)"
15+
required: true
16+
type: string
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
24+
steps:
25+
- uses: actions/checkout@v6
26+
with:
27+
ref: ${{ github.event.inputs.tag || github.ref }}
28+
fetch-depth: 0 # Fetch full history (needed for release notes generation)
29+
fetch-tags: true # Ensure tags are fetched (needed for release notes generation)
30+
31+
- name: Determine release type
32+
id: release_type
33+
run: |
34+
TAG="${{ github.event.inputs.tag || github.ref_name }}"
35+
# Check if tag contains prerelease markers (- or +) after SemVer core
36+
# Lines 5-6 in trigger: [0-9]+.[0-9]+.[0-9]+* and [a-zA-Z]+[0-9]+.[0-9]+.[0-9]+*
37+
if [[ $TAG =~ ^[a-zA-Z]*[0-9]+\.[0-9]+\.[0-9]+([-]) ]]; then
38+
echo "is_prerelease=true" >> $GITHUB_OUTPUT
39+
echo "is_draft=false" >> $GITHUB_OUTPUT
40+
echo "Release type: PRERELEASE"
41+
elif [[ $TAG =~ ^[a-zA-Z]*[0-9]+\.[0-9]+\.[0-9]+([+]) ]]; then
42+
echo "is_prerelease=false" >> $GITHUB_OUTPUT
43+
echo "is_draft=true" >> $GITHUB_OUTPUT
44+
echo "Release type: DRAFT"
45+
else
46+
echo "is_prerelease=false" >> $GITHUB_OUTPUT
47+
echo "is_draft=false" >> $GITHUB_OUTPUT
48+
echo "Release type: STABLE"
49+
fi
50+
51+
- name: Create release notes
52+
id: release_notes
53+
env:
54+
GITHUB_TOKEN: ${{ github.token }}
55+
run: |
56+
gh ext install devx-cafe/gh-tt
57+
mkdir -p .tmp/release
58+
gh tt semver note --filename .tmp/release/RELEASENOTES.md
59+
echo "Generating release notes..."
60+
cat .tmp/release/RELEASENOTES.md >> $GITHUB_STEP_SUMMARY
61+
62+
63+
# Build the release assets - and collects the "packkage". to release
64+
- name: collect artifacts
65+
run: |
66+
mkdir -p .tmp/release
67+
cp ./README.md .tmp/release/
68+
69+
# Nice to have a version.txt in the release assets, so we know what commit and tag the release was built from
70+
- name: version.txt
71+
run: |
72+
mkdir -p .tmp/release
73+
echo "Build from ${{ github.repository }}" > .tmp/release/version.txt
74+
echo "Tag: ${{ github.ref_name }}" >> .tmp/release/version.txt
75+
echo "Commit: ${{ github.sha }}" >> .tmp/release/version.txt
76+
77+
# Package the release assets - in this case we just tar.gz the release folder,
78+
# but you should design it to any packaging needed for the specific project
79+
- name: Package release assets
80+
run: |
81+
mkdir -p .tmp/release
82+
TAG="${{ github.event.inputs.tag || github.ref_name }}"
83+
tar -czf ".tmp/takt-actions-${TAG}.tar.gz" -C .tmp/release .
84+
85+
# This files are "flattend" in the release, so If you need to keep the folder structure,
86+
# you should create an archive (tar ball) ...wi did that in the previous step, so now we just need
87+
# to upload the archive as the release asset
88+
- name: Create Release
89+
uses: softprops/action-gh-release@v1
90+
with:
91+
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
92+
files: |
93+
./.tmp/takt-actions-${{ github.event.inputs.tag || github.ref_name }}.tar.gz
94+
./.tmp/release/version.txt
95+
body_path: .tmp/release/RELEASENOTES.md
96+
draft: ${{ steps.release_type.outputs.is_draft }}
97+
prerelease: ${{ steps.release_type.outputs.is_prerelease }}
98+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/stage.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Stage
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
stage-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v6
13+
14+
- name: Mark the spot for stage deployment
15+
run: |
16+
echo "Stage deployment placeholder - ready for implementation"
17+
echo "Stage deployment placeholder - ready for implementation" >> $GITHUB_STEP_SUMMARY
18+
echo "go to \`.github/workflows/stage.yml\` and fill in the blanks..." >> .stage_deploy_placeholder
19+
20+
# A blank sheet!
21+
# Excited to see what yopu come up with!

.github/workflows/wrapup.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: wrapup
2+
on:
3+
workflow_dispatch:
4+
5+
push:
6+
branches:
7+
- "[0-9]*" # Isue branches
8+
- "copilot/*" # Copilot running in Agentic mode pushes branches with this prefix as default
9+
10+
concurrency:
11+
group: "wrapup"
12+
cancel-in-progress: false
13+
14+
15+
jobs:
16+
trunk-worthy:
17+
name: Check trunk worthyness
18+
runs-on: ubuntu-latest
19+
env:
20+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
permissions:
22+
contents: read
23+
statuses: write
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v6
28+
29+
- name: Mark pending
30+
run: ./.scripts/trunk-worthy mark-pending
31+
32+
- name: Set up runner environment
33+
uses: ./.github/actions/prep-runner
34+
35+
- name: Test trunk worthyness - mark statusses
36+
run: ./.scripts/trunk-worthy

docs/ready_pusher.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# SECRETS for the `READY_PUSHER`
2+
3+
The [TakT](https://www.lakruzz.com/stories/takt/) workflow which allows you to run a smooth Pull-Request free flow needs access to merge stuff into your trunk (`main`).
4+
5+
GitHub flows comes with a built-in worker-bee token. In the flows you can access it in `${{ secrets.GITHUB_TOKEN }}`
6+
7+
> [!CAUTION]
8+
> While the ${{ secrets.GITHUB_TOKEN }} can be lifted to `contents:write` permissions. GitHub actions treats
9+
> commits created with this token as a special case which:
10+
> **These commits will not trigger other workflows**
11+
12+
We need that! The `ready.yml` flow is designed to trigger the `stage.yml` flow.
13+
14+
## Solution
15+
16+
- In you developer profile settings Go and create a [**Fine-grained personal access token**](https://github.com/settings/personal-access-tokens)
17+
- Settings (recommended)
18+
- **Token name**: `TAKT_CONTENT_WRITE`
19+
- **Description**: `Used to support the workflows devx-cafe/gh-tt workflow`
20+
- **Ressource owner**: `<YOUR-ORGANIZATION>` (recommended) or `<USER>` if you don't have an organization
21+
- **Expiration**: `<A-LONG-TIME>`
22+
- **Repository access** `All` or `Only selected`
23+
- **Permissions**: `contents:write` _(nothing else is needed)_
24+
25+
When you are done you will be presented a `gho****` token (GitHub oAuth) \_this is the only time you'll see this, but possibly not the only time you'll need it! So store it in your favorite password wallet.
26+
27+
<!-- cspell:ignore Cemi Okxps -->
28+
29+
> [!TIP]
30+
> You can not store this in git!
31+
> If you do, GitHub will see 👀 it in the security scans going on in the background and
32+
> and it will revoke the token!
33+
> IF you want to store it in git, encode it with `base64` first and decode it when you need to use it:
34+
> Example:
35+
> If your token is `gho_1ZCCemiYAvkChNLJ4zOkxpsBh6X7FUZn25`
36+
>
37+
> ```bash
38+
> $ echo gho_1ZCCemiYAvkChNLJ4zOkxpsBh6X7FUZn25 | base64
39+
> Z2hvXzFaQ0NlbWlZQXZrQ2hOTEo0ek9reHBzQmg2WDdGVVpuMjUK
40+
> echo Z2hvXzFaQ0NlbWlZQXZrQ2hOTEo0ek9reHBzQmg2WDdGVVpuMjUK | base64 --decode
41+
> gho_1ZCCemiYAvkChNLJ4zOkxpsBh6X7FUZn25
42+
> ```
43+
44+
## Make it a Secret
45+
46+
### 1. Organization secret
47+
48+
Go to the organization **"Action secrets and variables"** page
49+
50+
`<https://github.com/organizations/<ORG>/settings/secrets/actions>`
51+
52+
Create a new organisation secret:
53+
54+
- **Name**: `READY_PUSHER`
55+
- **Secret**: `<TAKT_CONTENT_WRITE-VALUE>` (starts with `gho***`)
56+
57+
### 2. Repo secret:
58+
59+
Go to the repo **"Action secrets and variables"** page:
60+
61+
`<https://github.com/<USER|ORG>/<REPO-NAME>/settings/secrets/actions>`
62+
63+
Create a new secret:
64+
65+
- **Name**: `READY_PUSHER`
66+
- **Secret**: `<TAKT_CONTENT_WRITE-VALUE>` (starts with `gho***`)
67+
68+
## Use the secret
69+
70+
Regardless if you created the secret as a _repo_ or an _organizations_ wide secret you use it the same way.
71+
72+
When you need to manipulate a repo, push it back to origin and have possible flows trigger on the change, simply pass `${{ secrets.READY_PUSHER }}` at the token to the `checkout` action
73+
74+
```yaml
75+
...
76+
77+
jobs:
78+
some-job:
79+
80+
...
81+
82+
permissions:
83+
contents: write # Required if you plan to push back _ even with your own token
84+
85+
steps:
86+
87+
...
88+
89+
- uses: actions/checkout@v6
90+
with:
91+
fetch-depth: 0 # Required if you plan to push back - Fetch full history
92+
token: ${{ secrets.READY_PUSHER }} # Required if you want push backs to trigger other flows must have contents:write
93+
94+
```
95+
96+
See it live in the `ready.yml` flow

0 commit comments

Comments
 (0)