Skip to content

Commit

Permalink
Merge pull request #237 from uswitch/AIRSHIP-3063-gha-migration
Browse files Browse the repository at this point in the history
AIRSHIP-3063 GHA Migration
  • Loading branch information
meghaniankov authored Jan 10, 2024
2 parents fe4dbac + 0b401e2 commit bd75813
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 48 deletions.
46 changes: 0 additions & 46 deletions .drone.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pull_request

on: pull_request

permissions:
contents: read
id-token: write

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.2.2
- run: rake spec
64 changes: 64 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: push

on:
push:
branches:
- '**'

permissions:
contents: read
id-token: write

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.2.2
- run: rake spec

build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.2.2
- run: rake version
- run: rake build
- uses: actions/upload-artifact@v3
with:
name: pkg
path: pkg/

docker:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- uses: actions/download-artifact@v3
with:
name: pkg
path: pkg/
- id: meta
uses: docker/metadata-action@v4
with:
images: quay.io/uswitch/terrafying-components
tags: type=sha,prefix=,format=long,
- uses: docker/build-push-action@v4
with:
context: .
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
78 changes: 78 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: tag

on:
push:
tags:
- '*'

permissions:
contents: read
id-token: write

jobs:
build:
runs-on: ubuntu-latest
env:
GHA_TERRAFYING_VERSION: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.2.2
- run: rake version
- run: rake build
- uses: actions/upload-artifact@v3
with:
name: pkg
path: |
pkg/
lib/
push:
needs: build
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
GHA_TERRAFYING_VERSION: ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.2.2
- uses: actions/download-artifact@v3
with:
name: pkg
path: ./
- run: rake push

docker:
needs: build
runs-on: ubuntu-latest
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
steps:
- uses: actions/checkout@v4
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- uses: actions/download-artifact@v3
with:
name: pkg
path: ./
- id: meta
uses: docker/metadata-action@v4
with:
images: quay.io/uswitch/terrafying
tags: type=semver,pattern={{version}}
- uses: docker/build-push-action@v4
with:
context: .
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: "TERRAFYING_VERSION=${{ github.ref_name }}"
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ task :push do
sh("gem push --config-file .gemconfig pkg/terrafying-components-#{terrafying_version}.gem")
end

desc 'Update the version for terrafying-components to DRONE_TAG. (0.0.0 if DRONE_TAG not set)'
desc 'Update the version for terrafying-components to GHA_TERRAFYING_VERSION. (0.0.0 if GHA_TERRAFYING_VERSION not set)'
task :version do
ver = ENV['DRONE_TAG'] || '0.0.0'
ver = ENV['GHA_TERRAFYING_VERSION'] || '0.0.0'
version_file = 'lib/terrafying/components/version.rb'
content = File.read(version_file).gsub(/0\.0\.0/, ver)
File.open(version_file, 'w') { |file| file.puts content }
Expand Down

0 comments on commit bd75813

Please sign in to comment.