Skip to content

Commit

Permalink
Use actions/github-script
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlei committed Mar 5, 2024
1 parent 38857e5 commit 25411eb
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ jobs:

- name: Configure
id: config
run: |-
NPROC=$(nproc)
echo "NPROC=$((NPROC*2+1))" >> $GITHUB_ENV
echo "NPROC=$((NPROC*2+1))" >> $GITHUB_OUTPUT
uses: actions/github-script@v7
env:
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
with:
script: |
const os = require('os')
echo "repo-owner=${{ github.repository_owner }}" >> $GITHUB_OUTPUT
echo "repo-name=${GITHUB_REPOSITORY#*/docker-}" >> $GITHUB_OUTPUT
core.exportVariable('NPROC', os.cpus().length * 2)
core.setOutput('NPROC', os.cpus().length * 2)
core.setOutput('image-owner', process.env.GITHUB_REPOSITORY_OWNER)
core.setOutput('image-name', process.env.GITHUB_REPOSITORY_NAME.replace(/^docker-/, ''))
- name: Setup - Setup buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -62,8 +66,8 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |-
${{ steps.config.outputs.repo-owner }}/${{ steps.config.outputs.repo-name }}
ghcr.io/${{ steps.config.outputs.repo-owner }}/${{ steps.config.outputs.repo-name }}
${{ steps.config.outputs.image-owner }}/${{ steps.config.outputs.image-name }}
ghcr.io/${{ steps.config.outputs.image-owner }}/${{ steps.config.outputs.image-name }}
flavor: |-
latest=false
suffix=${{ matrix.suffix }}
Expand Down

0 comments on commit 25411eb

Please sign in to comment.