From 49c35c91e97aa11ddbed01228020f11ee08a82ad Mon Sep 17 00:00:00 2001 From: nmburgan <13688219+nmburgan@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:36:23 -0800 Subject: [PATCH] Move promote task into GHA --- .github/workflows/promote.yml | 94 +++++++++++++++++++++++++++++++++++ .github/workflows/tests.yaml | 1 - tasks/promote.rake | 36 -------------- 3 files changed, 94 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/promote.yml delete mode 100644 tasks/promote.rake diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml new file mode 100644 index 0000000000..29d7c276de --- /dev/null +++ b/.github/workflows/promote.yml @@ -0,0 +1,94 @@ +name: Promote Component + +on: + workflow_dispatch: + inputs: + component: + description: 'Component name to promote' + required: true + type: string + ref: + description: 'Git ref/tag to promote. For puppet-runtime, use the tag that has been built and uploaded to openvox-artifacts.' + required: true + type: string + branch: + description: 'Branch to promote to (defaults to main)' + required: false + default: 'main' + type: string + +permissions: + contents: write + +env: + GIT_AUTHOR_NAME: OpenVoxProjectBot + GIT_AUTHOR_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com + GIT_COMMITTER_NAME: OpenVoxProjectBot + GIT_COMMITTER_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + +jobs: + promote: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Add SSH key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}" > ~/.ssh/github_actions + chmod 600 ~/.ssh/github_actions + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add ~/.ssh/github_actions + + - name: Setup git + run: | + git config --global user.email "$GIT_AUTHOR_EMAIL" + git config --global user.name "$GIT_AUTHOR_NAME" + git config --global gpg.format ssh + git config --global user.signingkey ~/.ssh/github_actions + git config --global commit.gpgsign true + git config --global tag.gpgsign true + + - name: Validate component exists + run: | + component="${{ inputs.component }}" + if [[ ! -f "packaging/configs/components/${component}.json" ]]; then + echo "::error::Could not find packaging/configs/components/${component}.json" + exit 1 + fi + + - name: Generate component JSON + id: generate + run: | + component="${{ inputs.component }}" + ref="${{ inputs.ref }}" + + if [[ "${component}" == "puppet-runtime" ]]; then + # Munge the ref: replace - with . + munged="${ref//-/.}" + json="{\"location\":\"https://s3.osuosl.org/openvox-artifacts/${component}/${ref}/\",\"version\":\"${munged}\"}" + else + json="{\"url\":\"https://github.com/openvoxproject/${component}.git\",\"ref\":\"${ref}\"}" + fi + + echo "json=${json}" >> "$GITHUB_OUTPUT" + echo "Generated JSON: ${json}" + + - name: Write component JSON + run: | + component="${{ inputs.component }}" + echo '${{ steps.generate.outputs.json }}' > "packaging/configs/components/${component}.json" + echo "Wrote packaging/configs/components/${component}.json:" + cat "packaging/configs/components/${component}.json" + + - name: Commit component promotion + uses: stefanzweifel/git-auto-commit-action@v6 + with: + commit_user_name: ${{ env.GIT_COMMITTER_NAME }} + commit_user_email: ${{ env.GIT_COMMITTER_EMAIL }} + commit_author: '${{ env.GIT_AUTHOR_NAME }} <${{ env.GIT_AUTHOR_EMAIL }}>' + commit_message: "Promote ${{ inputs.component }} ${{ inputs.ref }}" + branch: ${{ inputs.branch }} + file_pattern: "packaging/configs/components/${{ inputs.component }}.json" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c8854f7620..750b44fab5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -125,7 +125,6 @@ jobs: run: | bundle exec rake rubocop bundle exec rake -T | grep vox:build - bundle exec rake -T | grep vox:promote bundle exec rake -T | grep vox:upload working-directory: packaging diff --git a/tasks/promote.rake b/tasks/promote.rake deleted file mode 100644 index 747ee51fcf..0000000000 --- a/tasks/promote.rake +++ /dev/null @@ -1,36 +0,0 @@ -namespace :vox do - desc 'Promote a component with a given ref into this repo. For puppet-runtime and pxp-agent, use the tag that has been built and uploaded to openvox-artifacts.' - task :promote, [:component, :ref] do |_, args| - component = args[:component] - ref = args[:ref] - - abort 'You must specify a component.' if component.nil? || component.empty? - abort "Could not find configs/components/#{component}.json" unless File.exist?("packaging/configs/components/#{component}.json") - abort 'You must provide a ref.' if ref.nil? || ref.empty? - - if component == 'puppet-runtime' - munged = ref.gsub('-', '.') - data = <<~DATA - {"location":"https://s3.osuosl.org/openvox-artifacts/#{component}/#{ref}/","version":"#{munged}"} - DATA - else - data = <<~DATA - {"url":"https://github.com/openvoxproject/#{component}.git","ref":"#{ref}"} - DATA - end - - branch = run_command('git rev-parse --abbrev-ref HEAD') - - Dir.chdir('packaging') do - puts "Writing #{component}.json" - File.write("configs/components/#{component}.json", data) - run_command("git add configs/components/#{component}.json") - puts 'Creating commit' - run_command("git commit -m 'Promote #{component} #{ref}'") - if ENV['NOPUSH'].nil? - puts 'Pushing to origin' - run_command("git push origin #{branch}") - end - end - end -end