Skip to content

Commit

Permalink
Merge pull request #107 from steveax/maint-add-testing-release-securi…
Browse files Browse the repository at this point in the history
…ty-workflows

(maint) add testing, release, and security workflows
  • Loading branch information
steveax authored Jan 29, 2024
2 parents 1d32082 + 76363b8 commit 105d5ab
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Tag Release & Push Gem

on: workflow_dispatch

jobs:
release:
name: Validate Docs, Tag, and Push Gem
runs-on: ubuntu-latest
if: github.repository == 'puppetlabs/beaker-answers'

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
clean: true
fetch-depth: 0

- name: Get New Version
id: nv
run: |
version=$(grep STRING lib/beaker-answers/version.rb |rev |cut -d "'" -f2 |rev)
echo "version=$version" >> $GITHUB_OUTPUT
echo "Found version $version from lib/beaker-answers/version.rb"
- name: Get Current Version
uses: actions/github-script@v7
id: cv
with:
script: |
const { data: response } = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
})
console.log(`The latest release is ${response.tag_name}`)
return response.tag_name
result-encoding: string

- name: Tag Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.nv.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
bodyfile: release-notes.md
draft: false
prerelease: false

- name: Set up Ruby 2.7
uses: actions/setup-ruby@v1
with:
version: 2.7.x

- name: Build gem
run: gem build *.gemspec

- name: Publish gem
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push *.gem
env:
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
39 changes: 39 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Security
on:
workflow_dispatch:
push:
branches:
- main

jobs:
scan:
name: Mend Scanning
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
# setup a package lock if one doesn't exist, otherwise do nothing
- name: check lock
run: '[ -f "Gemfile.lock" ] && echo "package lock file exists, skipping" || bundle lock'
# install java
- uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
# download mend
- name: download_mend
run: curl -o wss-unified-agent.jar https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar
- name: run mend
run: java -jar wss-unified-agent.jar
env:
WS_APIKEY: ${{ secrets.MEND_API_KEY }}
WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent
WS_USERKEY: ${{ secrets.MEND_TOKEN }}
WS_PRODUCTNAME: RE
WS_PROJECTNAME: ${{ github.event.repository.name }}
23 changes: 23 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Testing

on:
pull_request:
branches:
- main

jobs:
spec_tests:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version:
- '2.7'
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run spec tests
run: bundle exec rake test
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This repo is owned by the Installer team
* @puppetlabs/installer-and-management
* @puppetlabs/dumpling @puppetlabs/skeletor

0 comments on commit 105d5ab

Please sign in to comment.