-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
129 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,132 +9,7 @@ concurrency: | |
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
ruby-version: [3.1.4, 3.2.3, 3.3.0] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Ruby ${{ matrix.ruby-version }} | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
ruby-version: ${{ matrix.ruby-version }} | ||
|
||
- name: Lint | ||
run: bundle exec rubocop | ||
|
||
- name: Test | ||
run: bundle exec rspec | ||
|
||
release: | ||
name: Release | ||
if: github.ref_name == 'main' | ||
needs: build | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check for version bump | ||
id: version-check | ||
run: | | ||
if git diff --quiet HEAD^ -- lib/static_collection/version.rb; then | ||
echo "Version did not change" | ||
echo "version_changed=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "Version did change" | ||
echo "version_changed=true" >> $GITHUB_OUTPUT | ||
fi | ||
- uses: ruby/setup-ruby@v1 | ||
if: steps.version-check.outputs.version_changed == 'true' | ||
with: | ||
bundler-cache: true | ||
|
||
- name: Release the gem | ||
if: steps.version-check.outputs.version_changed == 'true' | ||
run: | | ||
mkdir -p ~/.gem | ||
cat << EOF > ~/.gem/credentials | ||
--- | ||
:github: Bearer ${GITHUB_TOKEN} | ||
:rubygems_api_key: ${RUBYGEMS_API_KEY} | ||
EOF | ||
chmod 0600 ~/.gem/credentials | ||
git config user.email "[email protected]" | ||
git config user.name "Wolfbot" | ||
bundle exec rake release | ||
env: | ||
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | ||
|
||
- name: Notify slack on failure | ||
if: failure() | ||
uses: slackapi/[email protected] | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.BEPLAT_PUBLIC_REPOS_SLACK_TOKEN }} | ||
with: | ||
channel-id: ${{ vars.DEVELOPER_TOOLS_ALERTS_SLACK_CHANNEL }} | ||
payload: | | ||
{ | ||
"text": "GitHub Action failed ${{ github.event.head_commit.url }}", | ||
"blocks": [ | ||
{ | ||
"type": "header", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "Job Failed. :red_circle:", | ||
"emoji": true | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"fields": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Workflow*: ${{ github.workflow }}" | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Job*: ${{ github.job }}" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "section", | ||
"fields": [ | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Project*:\n${{ github.repository }}" | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Branch*:\n${{ github.ref_name }}" | ||
}, | ||
{ | ||
"type": "mrkdwn", | ||
"text": "*Author*:\n${{ github.actor }}" | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "actions", | ||
"elements": [ | ||
{ | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "View Job" | ||
}, | ||
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{github.run_id}}/attempts/${{github.run_attempt}}" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
build_and_publish: | ||
name: Build and Publish | ||
uses: wealthsimple/public-github-workflows/.github/workflows/ruby-gem-build.yaml@reusable-ruby-gem-workflow | ||
secrets: inherit |