|
| 1 | +name: Promote Component |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + component: |
| 7 | + description: 'Component name to promote' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + ref: |
| 11 | + description: 'Git ref/tag to promote. For puppet-runtime, use the tag that has been built and uploaded to openvox-artifacts.' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + branch: |
| 15 | + description: 'Branch to promote to (defaults to main)' |
| 16 | + required: false |
| 17 | + default: 'main' |
| 18 | + type: string |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: write |
| 22 | + |
| 23 | +env: |
| 24 | + GIT_AUTHOR_NAME: OpenVoxProjectBot |
| 25 | + GIT_AUTHOR_EMAIL: [email protected] |
| 26 | + GIT_COMMITTER_NAME: OpenVoxProjectBot |
| 27 | + GIT_COMMITTER_EMAIL: [email protected] |
| 28 | + SSH_AUTH_SOCK: /tmp/ssh_agent.sock |
| 29 | + |
| 30 | +jobs: |
| 31 | + promote: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - name: Checkout repository |
| 35 | + uses: actions/checkout@v6 |
| 36 | + |
| 37 | + - name: Add SSH key |
| 38 | + run: | |
| 39 | + mkdir -p ~/.ssh |
| 40 | + echo "${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}" > ~/.ssh/github_actions |
| 41 | + chmod 600 ~/.ssh/github_actions |
| 42 | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null |
| 43 | + ssh-add ~/.ssh/github_actions |
| 44 | +
|
| 45 | + - name: Setup git |
| 46 | + run: | |
| 47 | + git config --global user.email "$GIT_AUTHOR_EMAIL" |
| 48 | + git config --global user.name "$GIT_AUTHOR_NAME" |
| 49 | + git config --global gpg.format ssh |
| 50 | + git config --global user.signingkey ~/.ssh/github_actions |
| 51 | + git config --global commit.gpgsign true |
| 52 | + git config --global tag.gpgsign true |
| 53 | +
|
| 54 | + - name: Validate component exists |
| 55 | + run: | |
| 56 | + component="${{ inputs.component }}" |
| 57 | + if [[ ! -f "packaging/configs/components/${component}.json" ]]; then |
| 58 | + echo "::error::Could not find packaging/configs/components/${component}.json" |
| 59 | + exit 1 |
| 60 | + fi |
| 61 | +
|
| 62 | + - name: Generate component JSON |
| 63 | + id: generate |
| 64 | + run: | |
| 65 | + component="${{ inputs.component }}" |
| 66 | + ref="${{ inputs.ref }}" |
| 67 | +
|
| 68 | + if [[ "${component}" == "puppet-runtime" ]]; then |
| 69 | + # Munge the ref: replace - with . |
| 70 | + munged="${ref//-/.}" |
| 71 | + json="{\"location\":\"https://s3.osuosl.org/openvox-artifacts/${component}/${ref}/\",\"version\":\"${munged}\"}" |
| 72 | + else |
| 73 | + json="{\"url\":\"https://github.com/openvoxproject/${component}.git\",\"ref\":\"${ref}\"}" |
| 74 | + fi |
| 75 | +
|
| 76 | + echo "json=${json}" >> "$GITHUB_OUTPUT" |
| 77 | + echo "Generated JSON: ${json}" |
| 78 | +
|
| 79 | + - name: Write component JSON |
| 80 | + run: | |
| 81 | + component="${{ inputs.component }}" |
| 82 | + echo '${{ steps.generate.outputs.json }}' > "packaging/configs/components/${component}.json" |
| 83 | + echo "Wrote packaging/configs/components/${component}.json:" |
| 84 | + cat "packaging/configs/components/${component}.json" |
| 85 | +
|
| 86 | + - name: Commit component promotion |
| 87 | + uses: stefanzweifel/git-auto-commit-action@v6 |
| 88 | + with: |
| 89 | + commit_user_name: ${{ env.GIT_COMMITTER_NAME }} |
| 90 | + commit_user_email: ${{ env.GIT_COMMITTER_EMAIL }} |
| 91 | + commit_author: '${{ env.GIT_AUTHOR_NAME }} <${{ env.GIT_AUTHOR_EMAIL }}>' |
| 92 | + commit_message: "Promote ${{ inputs.component }} ${{ inputs.ref }}" |
| 93 | + branch: ${{ inputs.branch }} |
| 94 | + file_pattern: "packaging/configs/components/${{ inputs.component }}.json" |
0 commit comments