Skip to content

Commit

Permalink
auto-update on new ecs tags
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkroh committed Sep 16, 2023
1 parent 35c6ef1 commit 5362cba
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This is a hack to update the code when new ECS tags are pushed.
name: generate

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- 'main'
workflow_dispatch:

jobs:
ecs-generate:
permissions:
# Allow job to write to the branch.
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: 1.21
cache-dependency-path: ./internal/generator/go.sum

- name: generate
working-directory: ./internal/generator
run: go run .

- name: check for modified versions
id: is-changed
run: echo "modified=$(if git status --porcelain | grep -q -E 'internal/version'; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT

- name: get elastic/ecs version
id: ecs-version
run: echo "version=$(cd ~/.ecs-generator/git/ecs; git describe --tags)" >> $GITHUB_OUTPUT

- name: commit updated code
if: steps.is-changed.outputs.modified == 'true'
env:
ECS_VERSION: ${{ steps.ecs-version.version.commit }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add -u
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git commit -m "Update to elastic/ecs@${ECS_VERSION}
Update code based on https://github.com/elastic/ecs/releases/tag/${ECS_VERSION}"
git push

0 comments on commit 5362cba

Please sign in to comment.