-
Notifications
You must be signed in to change notification settings - Fork 41
Modular GitHub actions and rework of workflows #397
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
cf7622e
Base rework of github actions, WIP
Jasrags 877d412
Added actions/checkout@v4 before other steps
Jasrags 791a1b5
Added actions/checkout@v4 before other steps
Jasrags 81b7760
Added permissions block
Jasrags 24e0593
Added pull-requests: read to test workflow
Jasrags bb5e262
Added actions/checkout@v4 before other steps
Jasrags 6324e6f
Testing auto-tag
Jasrags e102778
Testing auto-tag
Jasrags 6a581e6
Testing auto-tag #patch
Jasrags 131de16
Testing auto-tag #patch
Jasrags f1df3a3
Cleaning up workflow files
Jasrags 217de0f
Updating notify discord
Jasrags a5a7277
Update branch triggers for auto-tag
Jasrags 735bba1
Break out to use the discord-notify action only on PR open and refact…
Jasrags 1a00f25
removed unused notification code
Jasrags b532c39
Update .github/workflows/auto-tag.yml
Jasrags File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| name: "Codegen and Test" | ||
| description: "Run go generate and go test" | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - run: go generate ./... | ||
| shell: bash | ||
| - run: go test ./... | ||
| shell: bash |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: "Discord Webhook" | ||
| description: "Send PR info to Discord" | ||
| inputs: | ||
| webhook-url: | ||
| description: "Discord webhook URL" | ||
| required: true | ||
| pr-title: | ||
| description: "Title of the pull request" | ||
| required: false | ||
| pr-body: | ||
| description: "Body of the pull request" | ||
| required: false | ||
| pr-url: | ||
| description: "URL of the pull request" | ||
| required: false | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: tsickert/[email protected] | ||
| with: | ||
| webhook-url: ${{ inputs.webhook-url }} | ||
| embed-title: ${{ inputs.pr-title }} | ||
| embed-description: ${{ inputs.pr-body }} | ||
| embed-url: ${{ inputs.pr-url }} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| name: "Setup Go" | ||
| description: "Checkout and setup Go using go.mod" | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: 'go.mod' |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Auto Tag | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - '**' | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| tag: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Needed to access all tags | ||
|
|
||
| - name: Create tag using commit message | ||
| id: tagger | ||
| uses: mathieudutour/[email protected] | ||
| with: | ||
| tag_prefix: 'v' | ||
| default_bump: 'patch' | ||
| default_prerelease_bump: 'prerelease' | ||
| dry_run: false # Set to false for actual tagging in production | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,9 @@ | ||
| # This workflow will: build gomud for multiple os/architectures | ||
| # archive the binaries and create a new release for users to easily download | ||
|
|
||
| name: Build and release | ||
|
|
||
| on: | ||
| push: | ||
| tags: ['v*.*.*'] | ||
| branches: | ||
| - master | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
@@ -18,33 +16,15 @@ jobs: | |
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Show version | ||
| run: echo 'Releasing version $RELEASE_VERSION' | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
|
|
||
| - name: Run code generation | ||
| run: go generate ./... | ||
|
|
||
| - name: Run tests | ||
| run: go test ./... | ||
| - uses: actions/checkout@v4 | ||
| - uses: ./.github/actions/setup-go | ||
| - uses: ./.github/actions/codegen-and-test | ||
|
|
||
| build: | ||
| runs-on: ubuntu-latest | ||
| needs: 'test' | ||
| needs: test | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
| - uses: ./.github/actions/setup-go | ||
|
|
||
| - name: Create bin directory | ||
| run: mkdir -p bin/ | ||
|
|
@@ -75,7 +55,7 @@ jobs: | |
|
|
||
| release: | ||
| runs-on: ubuntu-latest | ||
| needs: "build" | ||
| needs: build | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
|
|
@@ -88,8 +68,7 @@ jobs: | |
| - name: Set short git commit SHA | ||
| id: vars | ||
| run: | | ||
| calculatedSha=$(git rev-parse --short ${{ github.sha }}) | ||
| echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV | ||
| echo "COMMIT_SHORT_SHA=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV | ||
|
|
||
| - name: Archive release | ||
| run: zip -r bin/${{ env.RELEASE_FILENAME }}-${{ env.RELEASE_VERSION }}.zip bin/ | ||
|
|
@@ -102,26 +81,3 @@ jobs: | |
| fail_on_unmatched_files: true | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| message: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/github-script@v6 | ||
| id: get_pr_data | ||
| with: | ||
| script: | | ||
| return ( | ||
| await github.rest.repos.listPullRequestsAssociatedWithCommit({ | ||
| commit_sha: context.sha, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| }) | ||
| ).data[0]; | ||
| - name: Discord Webhook Action | ||
| uses: tsickert/[email protected] | ||
| with: | ||
| webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} | ||
| embed-title: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).title || '🎉 New update on `master` branch' }} | ||
| embed-description: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).body || 'No description provided.' }} | ||
| embed-url: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).html_url || github.event.compare }} | ||
|
|
||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: Notify Discord | ||
|
|
||
| on: | ||
|
||
| pull_request: | ||
| types: | ||
| - opened | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| notify-discord: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get PR Metadata | ||
| if: github.event_name == 'pull_request' | ||
| uses: actions/github-script@v6 | ||
| id: pr_meta | ||
| with: | ||
| script: | | ||
| core.setOutput('title', context.payload.pull_request.title || '') | ||
| core.setOutput('body', context.payload.pull_request.body || '') | ||
| core.setOutput('url', context.payload.pull_request.html_url || '') | ||
|
|
||
| - name: Get Release Metadata | ||
| if: github.event_name == 'release' | ||
| uses: actions/github-script@v6 | ||
| id: release_meta | ||
| with: | ||
| script: | | ||
| core.setOutput('title', context.payload.release.name || context.payload.release.tag_name || '') | ||
| core.setOutput('body', context.payload.release.body || '') | ||
| core.setOutput('url', context.payload.release.html_url || '') | ||
|
|
||
| - name: Send Discord Message | ||
| uses: ./.github/actions/discord-webhook | ||
| with: | ||
| webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} | ||
| pr-title: ${{ steps.pr_meta.outputs.title }}${{ steps.release_meta.outputs.title }} | ||
| pr-body: ${{ steps.pr_meta.outputs.body }}${{ steps.release_meta.outputs.body }} | ||
| pr-url: ${{ steps.pr_meta.outputs.url }}${{ steps.release_meta.outputs.url }} | ||
|
||
This file contains hidden or 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 file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,19 @@ | ||
| name: run-tests | ||
| name: Run Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [master] | ||
| workflow_dispatch: | ||
| branches: | ||
| - master | ||
| - '**' | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
|
|
||
| - name: Run code generation | ||
| run: go generate ./... | ||
|
|
||
| - name: Run tests | ||
| run: make test | ||
| - uses: ./.github/actions/setup-go | ||
| - uses: ./.github/actions/codegen-and-test |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow is only triggered on
pull_request.opened, but includes logic forreleaseevents. Add arelease: types: [published]trigger (or similar) underonto send notifications when new releases are published.