-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add workflow templates #1
base: main
Are you sure you want to change the base?
Changes from all commits
0269f04
e4b33d0
e95066f
2ca34a1
55a34c7
1b47909
6d20984
7d0d499
79296c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||||
# SPDX-License-Identifier: Apache-2.0 | ||||||||
# Copyright 2025 Canonical Ltd. | ||||||||
name: "Create Github release" | ||||||||
description: "Create a GitHub release using the provided version" | ||||||||
|
||||||||
inputs: | ||||||||
VERSION: | ||||||||
description: "Version to release on Github" | ||||||||
type: string | ||||||||
required: true | ||||||||
|
||||||||
runs: | ||||||||
using: "composite" | ||||||||
steps: | ||||||||
- name: "API request to create release" | ||||||||
shell: bash | ||||||||
run: | | ||||||||
if gh release create "${{ inputs.VERSION }}" --generate-notes; then | ||||||||
echo "Release ${{ inputs.VERSION }} created ✅" >> "$GITHUB_STEP_SUMMARY" | ||||||||
echo "Release ${{ inputs.VERSION }} created ✅" | ||||||||
else | ||||||||
echo "Failed to create release ${{ inputs.VERSION }} ❌" >> "$GITHUB_STEP_SUMMARY" | ||||||||
echo "Failed to create release ${{ inputs.VERSION }} ❌" | ||||||||
fi | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add end of line
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||||
# SPDX-License-Identifier: Apache-2.0 | ||||||||
# Copyright 2025 Canonical Ltd. | ||||||||
name: Branch Release | ||||||||
|
||||||||
on: | ||||||||
workflow_run: | ||||||||
workflows: ["Tag GitHub"] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about something like this
Suggested change
|
||||||||
types: | ||||||||
- completed | ||||||||
|
||||||||
jobs: | ||||||||
branch-release: | ||||||||
runs-on: ubuntu-latest | ||||||||
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.outputs.release_branch == 'true' }} | ||||||||
env: | ||||||||
GITHUB_TOKEN: ${{ secrets.GH_OMEC_PAT }} | ||||||||
steps: | ||||||||
- uses: actions/checkout@v4 | ||||||||
|
||||||||
- uses: peterjgrainger/[email protected] | ||||||||
with: | ||||||||
branch: "rel-${{ github.event.workflow_run.outputs.version_branch }}" | ||||||||
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just in case, have you checked what we can do regarding the creation of release branches (branch name is different than the content of the version file)? For example, in the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2025 Canonical Ltd. | ||
name: Build | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch_name: | ||
description: Name of the branch to checkout | ||
required: false | ||
type: string | ||
default: ${{ github.ref }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.branch_name }} | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- name: Get Dependencies | ||
run: go mod download | ||
Comment on lines
+26
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need this step? We did not need it before |
||
|
||
- name: Build | ||
run: go build ./... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2025 Canonical Ltd. | ||
name: Docker Build | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch_name: | ||
description: Name of the branch to checkout | ||
required: false | ||
type: string | ||
default: ${{ github.ref }} | ||
|
||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.branch_name }} | ||
|
||
- name: Build Docker image | ||
run: make docker-build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2025 Canonical Ltd. | ||
name: Fossa Scan | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch_name: | ||
description: Name of the branch to checkout | ||
required: false | ||
type: string | ||
default: ${{ github.ref }} | ||
|
||
jobs: | ||
fossa-scan: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.branch_name }} | ||
|
||
- name: FOSSA scan | ||
uses: fossa-contrib/fossa-action@v3 | ||
with: | ||
fossa-api-key: 0c3bbcdf20e157bbd487dae173751b28 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2025 Canonical Ltd. | ||
name: Hadolint | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch_name: | ||
description: Name of the branch to checkout. Defaults to the branch that triggered the action. | ||
required: false | ||
type: string | ||
default: ${{ github.ref }} | ||
|
||
jobs: | ||
hadolint: | ||
name: Dockerfile Linter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.branch_name }} | ||
|
||
- name: Dockerfile linter | ||
uses: hadolint/[email protected] | ||
# Ignoring: | ||
# DL3008 warning: Pin versions in apt get install (e.g., apt-get install <package>=<version>); and | ||
# DL3018 warning: Pin versions in apk add (e.g., apk add <package>=<version>) | ||
with: | ||
dockerfile: Dockerfile | ||
ignore: DL3008,DL3018 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2025 Canonical Ltd. | ||
name: License Check | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch_name: | ||
description: Name of the branch to checkout | ||
required: false | ||
type: string | ||
default: ${{ github.ref }} | ||
|
||
jobs: | ||
license-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.branch_name }} | ||
|
||
- name: reuse lint | ||
uses: fsfe/reuse-action@v5 |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||||
# SPDX-License-Identifier: Apache-2.0 | ||||||||
# Copyright 2025 Canonical Ltd. | ||||||||
name: Lint PR | ||||||||
|
||||||||
on: | ||||||||
workflow_call: | ||||||||
inputs: | ||||||||
branch_name: | ||||||||
description: Name of the branch to checkout | ||||||||
required: false | ||||||||
type: string | ||||||||
default: ${{ github.ref }} | ||||||||
|
||||||||
jobs: | ||||||||
lint: | ||||||||
runs-on: ubuntu-latest | ||||||||
steps: | ||||||||
- name: Checkout Repository | ||||||||
uses: actions/checkout@v4 | ||||||||
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||
with: | ||||||||
ref: ${{ inputs.branch_name }} | ||||||||
submodules: true | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need to pull the submodules? I do not think any repo has a submodule
Suggested change
|
||||||||
|
||||||||
- name: Setup | ||||||||
uses: actions/setup-go@v5 | ||||||||
with: | ||||||||
go-version-file: 'go.mod' | ||||||||
|
||||||||
- name: Run golangci-lint | ||||||||
uses: golangci/[email protected] | ||||||||
with: | ||||||||
version: latest | ||||||||
args: -v --config ./.golangci.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2025 Canonical Ltd. | ||
name: Push Images | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
registry: | ||
description: "Registry URL" | ||
default: "registry.aetherproject.org" | ||
type: string | ||
docker_registry: | ||
description: "Docker Registry URL" | ||
default: "registry.aetherproject.org/" | ||
type: string | ||
docker_repository: | ||
description: "Docker repository" | ||
default: "sdcore/" | ||
type: string | ||
branch_name: | ||
description: Name of the branch to checkout | ||
required: false | ||
type: string | ||
default: ${{ github.ref_name }} | ||
|
||
jobs: | ||
push-images: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'omec-project' | ||
env: | ||
REGISTRY: ${{ inputs.registry }} | ||
DOCKER_REGISTRY: ${{ inputs.docker_registry }} | ||
DOCKER_REPOSITORY: ${{ inputs.docker_repository }} | ||
BRANCH_NAME: ${{ inputs.branch_name }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.BRANCH_NAME }} | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- run: echo GIT_SHA_SHORT=$(git rev-parse --short HEAD) >> $GITHUB_ENV | ||
|
||
- uses: docker/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ secrets.AETHER_REGISTRY_USERNAME }} | ||
password: ${{ secrets.AETHER_REGISTRY_PASSWORD }} | ||
|
||
- name: Build and push "${{ env.BRANCH_NAME }}-latest" Docker image | ||
env: | ||
DOCKER_TAG: ${{ env.BRANCH_NAME }}-latest | ||
run: | | ||
make docker-build | ||
make docker-push | ||
|
||
- name: Build and push "${{ env.BRANCH_NAME }}-GIT_SHA" Docker image | ||
env: | ||
DOCKER_TAG: ${{ env.BRANCH_NAME }}-${{ env.GIT_SHA_SHORT }} | ||
run: | | ||
make docker-build | ||
make docker-push | ||
Comment on lines
+46
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there was an agreement in one of the TST meetings about not needing to publish "non-release" images. If so, I think we can remove this file and push the release images to Docker Hub and the Aether registry |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,36 @@ | ||||||||||||
# SPDX-License-Identifier: Apache-2.0 | ||||||||||||
# Copyright 2025 Canonical Ltd. | ||||||||||||
name: Release Docker Image | ||||||||||||
|
||||||||||||
on: | ||||||||||||
workflow_run: | ||||||||||||
workflows: ["Tag GitHub"] | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about something like this?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both syntax is correct. |
||||||||||||
types: | ||||||||||||
- completed | ||||||||||||
|
||||||||||||
jobs: | ||||||||||||
release-image: | ||||||||||||
runs-on: ubuntu-latest | ||||||||||||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||||||||||||
env: | ||||||||||||
REGISTRY: docker.io | ||||||||||||
DOCKER_REGISTRY: docker.io/ | ||||||||||||
DOCKER_REPOSITORY: omecproject/ | ||||||||||||
steps: | ||||||||||||
- uses: actions/checkout@v4 | ||||||||||||
- uses: actions/setup-go@v5 | ||||||||||||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||
with: | ||||||||||||
go-version-file: 'go.mod' | ||||||||||||
|
||||||||||||
- uses: docker/[email protected] | ||||||||||||
with: | ||||||||||||
registry: ${{ env.REGISTRY }} | ||||||||||||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||||||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||||||||||||
|
||||||||||||
- name: Build and push release Docker image | ||||||||||||
env: | ||||||||||||
DOCKER_TAG: rel-${{ github.event.workflow_run.outputs.version }} | ||||||||||||
run: | | ||||||||||||
make docker-build | ||||||||||||
make docker-push |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,31 @@ | ||||||||||
# SPDX-License-Identifier: Apache-2.0 | ||||||||||
# Copyright 2025 Canonical Ltd. | ||||||||||
name: Stale issue/pr | ||||||||||
|
||||||||||
on: | ||||||||||
workflow_dispatch: | ||||||||||
inputs: | ||||||||||
days_before_stale: | ||||||||||
description: 'Days before stale' | ||||||||||
default: 120 | ||||||||||
required: true | ||||||||||
days_before_close: | ||||||||||
description: 'Days before close' | ||||||||||
default: 15 | ||||||||||
required: true | ||||||||||
|
||||||||||
jobs: | ||||||||||
stale: | ||||||||||
runs-on: ubuntu-latest | ||||||||||
steps: | ||||||||||
- uses: actions/[email protected] | ||||||||||
with: | ||||||||||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
stale-issue-message: 'This issue has been stale for 120 days and will be closed in 15 days. Comment to keep it open.' | ||||||||||
stale-pr-message: 'This pull request has been stale for 120 days and will be closed in 15 days. Comment to keep it open.' | ||||||||||
Comment on lines
+24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not the text for the number of days ("120" and "15") be changed based on the workflow input?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Done. |
||||||||||
stale-issue-label: 'stale/issue' | ||||||||||
stale-pr-label: 'stale/pr' | ||||||||||
days-before-stale: ${{ inputs.days_before_stale }} | ||||||||||
days-before-close: ${{ inputs.days_before_close }} | ||||||||||
exempt-issue-labels: 'important,bug' | ||||||||||
exempt-pr-labels: 'work-in-progress' |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||||||
# SPDX-License-Identifier: Apache-2.0 | ||||||||
# Copyright 2025 Canonical Ltd. | ||||||||
name: Static analysis | ||||||||
|
||||||||
on: | ||||||||
workflow_call: | ||||||||
inputs: | ||||||||
branch_name: | ||||||||
description: Name of the branch to checkout | ||||||||
required: false | ||||||||
type: string | ||||||||
default: ${{ github.ref }} | ||||||||
|
||||||||
jobs: | ||||||||
staticcheck: | ||||||||
name: Run Staticcheck | ||||||||
runs-on: ubuntu-latest | ||||||||
steps: | ||||||||
- name: Checkout repository | ||||||||
uses: actions/checkout@v4 | ||||||||
Comment on lines
+19
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||
with: | ||||||||
ref: ${{ inputs.branch_name }} | ||||||||
|
||||||||
- name: Setup | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||
uses: WillAbides/[email protected] | ||||||||
with: | ||||||||
go-version-file: 'go.mod' | ||||||||
|
||||||||
- uses: dominikh/[email protected] | ||||||||
with: | ||||||||
version: latest | ||||||||
install-go: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I understand that the GitHub runners have, by default, the GitHub client (gh) installed? Additionally, I should understand that this cannot be in the same GHA (i.e.,
tag-github
) and that is why it is in its own directory (actions), correct?