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

feat: add workflow templates #1

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions .github/actions/create-github-release/action.yml
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

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?

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add end of line

Suggested change
fi
fi

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

22 changes: 22 additions & 0 deletions .github/workflows/branch-release.yml
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"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like this

Suggested change
workflows: ["Tag GitHub"]
workflows:
- "Tag GitHub"

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
Copy link

@gab-arrobo gab-arrobo Mar 19, 2025

Choose a reason for hiding this comment

The 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 amf repo, branch rel-1.3 has VERSION file with content 1.4.0

30 changes: 30 additions & 0 deletions .github/workflows/build.yml
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

Choose a reason for hiding this comment

The 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 ./...
23 changes: 23 additions & 0 deletions .github/workflows/docker-build.yml
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
25 changes: 25 additions & 0 deletions .github/workflows/fossa-scan.yml
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
30 changes: 30 additions & 0 deletions .github/workflows/hadolint.yml
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
23 changes: 23 additions & 0 deletions .github/workflows/license-check.yml
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
33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/checkout@v4

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

with:
ref: ${{ inputs.branch_name }}
submodules: true

Choose a reason for hiding this comment

The 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
submodules: true


- 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
64 changes: 64 additions & 0 deletions .github/workflows/push-images.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
Copy link

@gab-arrobo gab-arrobo Mar 19, 2025

Choose a reason for hiding this comment

The 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
@omec-project/5gc-maintainers, do you remember what we agreed about the "non-release" images (e.g., 5gc-amf:main-latest and 5gc-amf:main-commitId)?

36 changes: 36 additions & 0 deletions .github/workflows/release-image.yml
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"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like this?

Suggested change
workflows: ["Tag GitHub"]
workflows:
- "Tag GitHub"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v4
- uses: actions/setup-go@v5

Copy link
Author

Choose a reason for hiding this comment

The 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
31 changes: 31 additions & 0 deletions .github/workflows/stale-issue.yml
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

Choose a reason for hiding this comment

The 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
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.'
stale-issue-message: 'This issue has been stale for ${{ inputs.days_before_stale }} days and will be closed in ${{ inputs.days_before_close}} days. Comment to keep it open.'
stale-pr-message: 'This pull request has been stale for ${{ inputs.days_before_stale }} days and will be closed in ${{ inputs.days_before_close}} days. Comment to keep it open.'

Copy link
Author

Choose a reason for hiding this comment

The 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'
32 changes: 32 additions & 0 deletions .github/workflows/static-analysis.yml
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/checkout@v4

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

with:
ref: ${{ inputs.branch_name }}

- name: Setup

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Setup
- name: Setup Go

Copy link
Author

Choose a reason for hiding this comment

The 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
Loading