Skip to content

Instantly share code, notes, and snippets.

@Integralist
Created September 12, 2024 07:15
Show Gist options
  • Save Integralist/8a6401fb294964984a27d73c2bd97664 to your computer and use it in GitHub Desktop.
Save Integralist/8a6401fb294964984a27d73c2bd97664 to your computer and use it in GitHub Desktop.
[GitHub Actions update app dependencies daily] #ci #gha #github #actions #cron #go #golang
name: Update Dependencies and Run Tests
on:
# Schedule to run at 9am UTC every day
schedule:
- cron: '0 9 * * *'
# Allow manual trigger via GitHub UI
workflow_dispatch:
jobs:
update-deps-and-test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Set up private Go modules
run: |
echo "Setting up GOPRIVATE and GitHub token"
echo "machine github.com login ${{ secrets.GH_PAT_CI }}" > ~/.netrc
env:
GOPRIVATE: "github.com/some_private_repo" # <<<<<<<<<<<<<<<<<< UPDATE THIS
- name: Update dependencies
run: |
go get -u -t ./...
go mod tidy
- name: Run tests
env:
GO_TESTARGS: "-count=1 -v -run=Test ./..."
run: go test -race -count=1 -v -run=Test ./...
- name: Commit changes
if: success()
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "build: update dependencies [skip ci]"
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment