Skip to content

Commit

Permalink
ci: test reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rperryng committed Jun 26, 2024
1 parent d0ed396 commit 7f9f4a2
Showing 1 changed file with 4 additions and 129 deletions.
133 changes: 4 additions & 129 deletions .github/workflows/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7f9f4a2

Please sign in to comment.