|
| 1 | +# |
| 2 | +# Use the GitHub API to tag the main branch of another repository. |
| 3 | +# |
| 4 | +name: Tag example-orchestrator-ui |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - '@orchestrator-ui/orchestrator-ui-components@[0-9]+.[0-9]+.[0-9]+' |
| 10 | + release: |
| 11 | + types: |
| 12 | + - published |
| 13 | + tags: |
| 14 | + - '@orchestrator-ui/orchestrator-ui-components@[0-9]+.[0-9]+.[0-9]+' |
| 15 | + |
| 16 | +# The main branch of the following repository will be tagged |
| 17 | +# with the version part (e.g. 0.3.1) of the tag trigger above. |
| 18 | +env: |
| 19 | + REPO: 'example-orchestrator-ui' |
| 20 | + |
| 21 | +jobs: |
| 22 | + docker: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + packages: write |
| 27 | + steps: |
| 28 | + - name: Create GitHub app token |
| 29 | + uses: actions/create-github-app-token@v1 |
| 30 | + id: app-token |
| 31 | + with: |
| 32 | + app-id: ${{ vars.RW_REPOSITORY_CONTENT_APP_ID }} |
| 33 | + private-key: ${{ secrets.RW_REPOSITORY_CONTENT_PRIVATE_KEY }} |
| 34 | + owner: ${{ github.repository_owner }} |
| 35 | + repositories: ${{ env.REPO }} |
| 36 | + - name: Get latest commit SHA |
| 37 | + id: sha |
| 38 | + uses: actions/github-script@v7 |
| 39 | + with: |
| 40 | + result-encoding: string |
| 41 | + script: | |
| 42 | + const commit = await github.rest.repos.getCommit({ |
| 43 | + owner: github.repository_owner, |
| 44 | + repo: env.REPO, |
| 45 | + ref: 'heads/main', |
| 46 | + }) |
| 47 | + return commit.data.sha |
| 48 | + - name: Extract REF from ref_name |
| 49 | + run: | |
| 50 | + REF_NAME=${{ github.ref_name }} |
| 51 | + REF=${REF_NAME/@orchestrator-ui\/orchestrator-ui-components@/} |
| 52 | + echo REF=${REF} >> $GITHUB_ENV |
| 53 | + - name: Add tag to repository |
| 54 | + uses: actions/github-script@v7 |
| 55 | + env: |
| 56 | + REF: ${{ format('refs/tags/{0}', env.REF) }} |
| 57 | + SHA: ${{ steps.sha.outputs.result }} |
| 58 | + with: |
| 59 | + github-token: ${{ steps.app-token.outputs.token }} |
| 60 | + script: | |
| 61 | + await github.rest.git.createRef({ |
| 62 | + owner: github.repository_owner, |
| 63 | + repo: env.REPO, |
| 64 | + ref: process.env.REF, |
| 65 | + sha: process.env.SHA, |
| 66 | + }) |
0 commit comments