From faed286dad404f927a287c6bf738cc42d24689f2 Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Tue, 2 Jan 2024 16:11:15 +0000 Subject: [PATCH 01/13] migrate to gha --- .github/workflows/push.yaml | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/push.yaml diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml new file mode 100644 index 0000000..d7a88e6 --- /dev/null +++ b/.github/workflows/push.yaml @@ -0,0 +1,54 @@ +name: push + +on: push + +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: bundle install + - run: rake spec + + build: + 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 + + docker: + 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 }} + - id: meta + uses: docker/metadata-action@v4 + with: + images: quay.io/uswitch/terrafying-components + tags: | + type=sha,prefix=,format=long, + type=ref,event=branch + - uses: docker/build-push-action@v4 + with: + context: . + labels: ${{ steps.meta.outputs.labels }} + push: true + tags: ${{ steps.meta.outputs.tags }} From 6eb46ea71c35fdfd3b556d0203c662b9d557ea3e Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Tue, 2 Jan 2024 16:12:32 +0000 Subject: [PATCH 02/13] add deps --- .github/workflows/push.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index d7a88e6..482a6b4 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -19,6 +19,7 @@ jobs: - run: rake spec build: + needs: test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -30,6 +31,7 @@ jobs: - run: rake build docker: + needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 190099930e6dd884fe04dc014c7798dd2755aeea Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Wed, 3 Jan 2024 08:56:09 +0000 Subject: [PATCH 03/13] artifact handling --- .github/workflows/push.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 482a6b4..6d81884 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -29,6 +29,10 @@ jobs: ruby-version: 3.2.2 - run: rake version - run: rake build + - uses: actions/upload-artifact@v3 + with: + name: pkg + path: pkg/ docker: needs: build @@ -41,6 +45,10 @@ jobs: 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: From 72623d23f9b8e23db561bbc49d36c72de5245511 Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Wed, 3 Jan 2024 11:35:14 +0000 Subject: [PATCH 04/13] add pull_req workflow and remove drone --- .drone.yml | 46 ----------------------------- .github/workflows/pull_request.yaml | 19 ++++++++++++ 2 files changed, 19 insertions(+), 46 deletions(-) delete mode 100644 .drone.yml create mode 100644 .github/workflows/pull_request.yaml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index b7cf294..0000000 --- a/.drone.yml +++ /dev/null @@ -1,46 +0,0 @@ -pipeline: - test: - image: ruby:3.2.2 - commands: - - bundle install - - rake spec - when: - event: [pull_request, push] - - build: - image: ruby:3.2.2 - commands: - - rake version - - rake build - when: - event: [push, tag] - - docker: - image: plugins/docker - repo: quay.io/uswitch/terrafying-components - registry: quay.io - secrets: [ docker_username, docker_password ] - tags: - - ${DRONE_COMMIT_SHA} - - ${DRONE_COMMIT_BRANCH} - when: - event: push - - push: - image: ruby:3.2.2 - secrets: [ rubygems_api_key ] - commands: - - rake push - when: - event: tag - - docker-tag: - image: plugins/docker - repo: quay.io/uswitch/terrafying-components - registry: quay.io - secrets: [ docker_username, docker_password ] - build_args: - - TERRAFYING_VERSION=${DRONE_TAG} - auto_tag: true - when: - event: tag diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 0000000..9b7cf29 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,19 @@ +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: bundle install + - run: rake spec From cbf28c8307b7379415f9d0f2d51eee833b67e8e7 Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Wed, 3 Jan 2024 11:40:51 +0000 Subject: [PATCH 05/13] change tags --- .github/workflows/push.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 6d81884..e349d3c 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -55,7 +55,7 @@ jobs: images: quay.io/uswitch/terrafying-components tags: | type=sha,prefix=,format=long, - type=ref,event=branch + type=semver,pattern={{version}} - uses: docker/build-push-action@v4 with: context: . From 22588decb7a13c3f6fac87b5d2b47def334eb207 Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Wed, 3 Jan 2024 15:30:05 +0000 Subject: [PATCH 06/13] add tag workflow --- .github/workflows/tag.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/tag.yaml diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml new file mode 100644 index 0000000..82cf29e --- /dev/null +++ b/.github/workflows/tag.yaml @@ -0,0 +1,24 @@ +name: tag + +on: + push: + tags: + - '*' + +permissions: + contents: read + id-token: write + +jobs: + push: + if: github.ref_name == 'master' && contains(github.ref, 'refs/tags/v') + env: + RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + 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 push From 894a39cf883a350dd31885485d7c13e7f5a401fc Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Fri, 5 Jan 2024 15:12:23 +0000 Subject: [PATCH 07/13] add TERRAFYING_VERSION build arg --- .github/workflows/push.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index e349d3c..6ca4acb 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -37,6 +37,8 @@ jobs: 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 @@ -62,3 +64,4 @@ jobs: labels: ${{ steps.meta.outputs.labels }} push: true tags: ${{ steps.meta.outputs.tags }} + build-args: "TERRAFYING_VERSION=${{ contains(github.ref, 'refs/tags/') && github.ref_name || '0.0.0' }}" From d4ad799242a2ad5d5d6754b9b09a9608d58d07ec Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Fri, 5 Jan 2024 15:42:37 +0000 Subject: [PATCH 08/13] update tag --- .github/workflows/push.yaml | 2 -- .github/workflows/tag.yaml | 1 - 2 files changed, 3 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 6ca4acb..bd22dda 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -37,8 +37,6 @@ jobs: 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 diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index 82cf29e..ac69684 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -11,7 +11,6 @@ permissions: jobs: push: - if: github.ref_name == 'master' && contains(github.ref, 'refs/tags/v') env: RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} runs-on: ubuntu-latest From 656b8a40bb5b252f1b990920e06d06fe153c9adf Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Tue, 9 Jan 2024 15:13:10 +0000 Subject: [PATCH 09/13] move buil and docker jobs to tag workflow --- .github/workflows/push.yaml | 12 ++++---- .github/workflows/tag.yaml | 57 ++++++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index bd22dda..71835d2 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -1,6 +1,9 @@ name: push -on: push +on: + push: + branches: + - '**' permissions: contents: read @@ -53,13 +56,10 @@ jobs: uses: docker/metadata-action@v4 with: images: quay.io/uswitch/terrafying-components - tags: | - type=sha,prefix=,format=long, - type=semver,pattern={{version}} + 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 }} - build-args: "TERRAFYING_VERSION=${{ contains(github.ref, 'refs/tags/') && github.ref_name || '0.0.0' }}" + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index ac69684..5846f1c 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -10,9 +10,30 @@ permissions: 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 }} + RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + GHA_TERRAFYING_VERSION: ${{ github.ref_name }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -20,4 +41,38 @@ jobs: 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 }}" From ab3628605bf85ab5f33ce76f2c205123521389f0 Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Tue, 9 Jan 2024 15:19:12 +0000 Subject: [PATCH 10/13] update rakefile --- Rakefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 313c642..91348b5 100644 --- a/Rakefile +++ b/Rakefile @@ -17,14 +17,15 @@ end desc 'Push gem to rubygems' task :push do - gem_config = { rubygems_api_key: rubygems_api_key }.to_yaml - File.open('.gemconfig', 'w') { |file| file.write(gem_config) } - sh("gem push --config-file .gemconfig pkg/terrafying-components-#{terrafying_version}.gem") + sh("echo pkg/terrafying-components-#{terrafying_version}.gem") + # gem_config = { rubygems_api_key: rubygems_api_key }.to_yaml + # File.open('.gemconfig', 'w') { |file| file.write(gem_config) } + # 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 } From eb0f46cc422354ceddb6784b0d5bc1ebeadca918 Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Tue, 9 Jan 2024 15:26:53 +0000 Subject: [PATCH 11/13] set docker push to false to test --- .github/workflows/push.yaml | 2 +- .github/workflows/tag.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 71835d2..2fec1b4 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -61,5 +61,5 @@ jobs: with: context: . labels: ${{ steps.meta.outputs.labels }} - push: true + push: false tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index 5846f1c..2163c89 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -73,6 +73,6 @@ jobs: with: context: . labels: ${{ steps.meta.outputs.labels }} - push: true + push: false tags: ${{ steps.meta.outputs.tags }} build-args: "TERRAFYING_VERSION=${{ github.ref_name }}" From 5992dbcbe6543ab67d8c46c361b66f3d548b87c5 Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Tue, 9 Jan 2024 15:30:18 +0000 Subject: [PATCH 12/13] revert changes for testing --- .github/workflows/push.yaml | 2 +- .github/workflows/tag.yaml | 2 +- Rakefile | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 2fec1b4..71835d2 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -61,5 +61,5 @@ jobs: with: context: . labels: ${{ steps.meta.outputs.labels }} - push: false + push: true tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index 2163c89..5846f1c 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -73,6 +73,6 @@ jobs: with: context: . labels: ${{ steps.meta.outputs.labels }} - push: false + push: true tags: ${{ steps.meta.outputs.tags }} build-args: "TERRAFYING_VERSION=${{ github.ref_name }}" diff --git a/Rakefile b/Rakefile index 91348b5..0c8fe3f 100644 --- a/Rakefile +++ b/Rakefile @@ -17,10 +17,9 @@ end desc 'Push gem to rubygems' task :push do - sh("echo pkg/terrafying-components-#{terrafying_version}.gem") - # gem_config = { rubygems_api_key: rubygems_api_key }.to_yaml - # File.open('.gemconfig', 'w') { |file| file.write(gem_config) } - # sh("gem push --config-file .gemconfig pkg/terrafying-components-#{terrafying_version}.gem") + gem_config = { rubygems_api_key: rubygems_api_key }.to_yaml + File.open('.gemconfig', 'w') { |file| file.write(gem_config) } + sh("gem push --config-file .gemconfig pkg/terrafying-components-#{terrafying_version}.gem") end desc 'Update the version for terrafying-components to GHA_TERRAFYING_VERSION. (0.0.0 if GHA_TERRAFYING_VERSION not set)' From 0b401e2ad78327368d73396a0fad34d6a6864d7d Mon Sep 17 00:00:00 2001 From: meghaniankov Date: Wed, 10 Jan 2024 08:37:59 +0000 Subject: [PATCH 13/13] remove bundle install --- .github/workflows/pull_request.yaml | 1 - .github/workflows/push.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 9b7cf29..c34c8f7 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -15,5 +15,4 @@ jobs: with: bundler-cache: true ruby-version: 3.2.2 - - run: bundle install - run: rake spec diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 71835d2..3afe64c 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -18,7 +18,6 @@ jobs: with: bundler-cache: true ruby-version: 3.2.2 - - run: bundle install - run: rake spec build: