user shell var substitution #80
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push container image | |
on: | |
push: | |
tags: | |
#- "[0-9]+.[0-9]+.[0-9]+.?*" | |
- "@orchestrator-ui/orchestrator-ui-components@[0-9]+.[0-9]+.[0-9]+" | |
# The main branch of the following repository will be tagged. | |
env: | |
REPOSITORY_OWNER: "hanstrompert" | |
REPOSITORY_NAME: "test-client" | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
environment: triggers | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/hanstrompert/test | |
tags: | | |
type=match,pattern=\d+.\d+.\d+.* | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
#- name: Build and push | |
# uses: docker/build-push-action@v5 | |
# with: | |
# context: . | |
# platforms: linux/amd64,linux/arm64 | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
- name: Get latest commit SHA for main of ${REPOSITORY_OWNER }/${REPOSITORY_NAME } | |
id: sha | |
uses: actions/github-script@v7 | |
env: | |
OWNER: ${{ env.REPOSITORY_OWNER }} | |
REPO: ${{ env.REPOSITORY_NAME }} | |
with: | |
result-encoding: string | |
script: | | |
const commit = await github.rest.repos.getCommit({ | |
owner: process.env.OWNER, | |
repo: process.env.REPO, | |
ref: 'heads/main', | |
}) | |
return commit.data.sha | |
- name: Extract REF from ref_name | |
run: | | |
REF_NAME=${{ github.ref_name }} | |
REF=${REF_NAME/@orchestrator-ui\/orchestrator-ui-components@/} | |
echo REF=${REF} >> $GITHUB_ENV | |
- name: Show SHA and REF | |
run: echo "will tag ${{ steps.sha.outputs.result }} with ${{ env.REF }}" | |
- name: Tag ${{ steps.sha.outputs.result }} of ${REPOSITORY_NAME} with ${{ env.REF }} | |
uses: actions/github-script@v7 | |
env: | |
OWNER: ${{ env.REPOSITORY_OWNER }} | |
REPO: ${{ env.REPOSITORY_NAME }} | |
REF: ${{ format('refs/tags/{0}', env.REF) }} | |
SHA: ${{ steps.sha.outputs.result }} | |
with: | |
github-token: ${{ secrets.TOKEN_CREATE_TAG_TEST_CLIENT }} | |
script: | | |
github.rest.git.createRef({ | |
owner: process.env.OWNER, | |
repo: process.env.REPO, | |
ref: process.env.REF, | |
sha: process.env.SHA, | |
}) |