Skip to content

Commit

Permalink
add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code committed Oct 14, 2024
1 parent a074c34 commit 809fb70
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
open-pull-requests-limit: 10
commit-message:
prefix: "chore(deps): "
reviewers:
- "zakir-code"
assignees:
- "zakir-code"
29 changes: 29 additions & 0 deletions .github/workflows/cleanup_caches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: cleanup caches by a branch
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
40 changes: 40 additions & 0 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Lint Golang

on:
push:
branches:
- main
paths:
- '**.go'
- 'go.mod'
- '.golangci.yml'
- '.github/workflows/golang.yml'
pull_request:
paths:
- '**.go'
- 'go.mod'
- '.golangci.yml'
- '.github/workflows/golang.yml'

permissions:
contents: read

concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Install golangci-lint
run: |
version=$(grep golangci_version= ./Makefile | awk -F '=' '{print $2}')
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin $version
- name: Make build and lint
run: make lint
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Publish Release

on:
push:
tags:
- 'v*'

permissions: write-all

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create Release
run: gh release create ${GITHUB_REF#refs/tags/} --title ${GITHUB_REF#refs/tags/} --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Tests

on:
push:
branches:
- main
paths:
- '**.go'
- 'go.mod'
- '*/go.mod'
pull_request:
paths:
- '**.go'
- 'go.mod'
- '*/go.mod'

permissions:
contents: read

concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Run make test
run: make test
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# go-sdk

[![Lint](https://github.com/pundiai/go-sdk/actions/workflows/golang.yml/badge.svg)](https://github.com/pundiai/go-sdk/actions/workflows/golang.yml)
[![Test](https://github.com/pundiai/go-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/pundiai/go-sdk/actions/workflows/test.yml)

0 comments on commit 809fb70

Please sign in to comment.