Fecth metrics #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a: | |
# - clean build of a Go project | |
# - run the tests | |
# - execute the generated binary | |
# - saves the output to a file | |
# - saves the file in the repository | |
name: Fecth metrics | |
on: | |
# manually trigger the workflow | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow pushing to the repository | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
GH_TOKEN: ${{ github.token }} | |
BRANCH: output-file-${{ github.run_number }} | |
GRAPHQL_TOKEN: ${{ secrets.GRAPHQL_TOKEN }} | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ^1.16 | |
- name: Get dependencies | |
run: | | |
cd backend | |
go get -v -t -d ./... | |
if [ -f Gopkg.toml ]; then | |
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | |
dep ensure | |
fi | |
- name: Build Go | |
run: make build | |
# - name: Test | |
# run: make test | |
- name: Run Go program and save output | |
id: run | |
run: | | |
$PWD/backend/bin/metrics > output.txt | |
echo "::set-output name=output::$(cat output.txt)" | |
- name: Upload output | |
# upload the output to the repository | |
uses: actions/upload-artifact@v3 | |
with: | |
name: output | |
path: output.txt | |
- name: Save output to file | |
run: echo "${{ steps.run.outputs.output }}" > output.txt | |
- name: Configure Git | |
run: | | |
git config user.name "Hassan Hawache" | |
git config user.email "hasan-dot@github.com" | |
git config credential.helper store | |
git config --global user.username "hasan-dot" | |
- name: Commit output file | |
run: | | |
git checkout -b $BRANCH | |
git add output.txt | |
git -c commit.gpgsign=false commit -m "Add output file" | |
git push origin $BRANCH | |
- name: Create Pull Request | |
run: | | |
gh pr create --base main --head $BRANCH --title "Output file PR" --body "Please review the output file changes." | |
- name: Merge Pull Request | |
run: | | |
gh pr merge --auto --delete-branch |