Use GitHub environment variables as template literals to reduce workflow maintenance and provide convenience for forked repositories. (#11142)

* Update cd.yml

* Update dockerimage.yml
This commit is contained in:
绛亽 2024-04-25 23:46:04 +08:00 committed by GitHub
parent b102219a13
commit 8063a7ff37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 49 additions and 32 deletions

View file

@ -11,14 +11,19 @@ on:
branches:
- master
# ref https://docs.github.com/zh/actions/learn-github-actions/variables
env:
repo_name_android: "siyuan-android"
repo_name: "siyuan"
repo_owner: "siyuan-note"
package_json: "app/package.json"
docker_hub_owner: "b3log"
docker_hub_repo: "siyuan"
jobs:
build:
name: build
runs-on: ubuntu-latest
strategy:
matrix:
string:
- package_json: "app/package.json"
permissions:
packages: write
contents: read
@ -34,7 +39,7 @@ jobs:
uses: sergeysova/jq-action@v2
id: version
with:
cmd: "jq .version ${{ matrix.string.package_json }} -r"
cmd: "jq .version ${{ env.package_json }} -r"
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
@ -67,9 +72,9 @@ jobs:
- name: Build the Docker image use Workflow Dispatch inputs' version
if: ${{ github.event_name == 'workflow_dispatch' && !github.event.inputs.image_tag == '' }}
run: |
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v${{ github.event.inputs.image_tag }} .
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t ${{ env.docker_hub_owner }}/${{ env.docker_hub_repo }}:latest -t ${{ env.docker_hub_owner }}/${{ env.docker_hub_repo }}:v${{ github.event.inputs.image_tag }} .
- name: Build the Docker image use package_json version
if: ${{ github.event_name == 'push' || github.event.inputs.image_tag == '' }}
run: |
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v${{ steps.version.outputs.value }} .
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t ${{ env.docker_hub_owner }}/${{ env.docker_hub_repo }}:latest -t ${{ env.docker_hub_owner }}/${{ env.docker_hub_repo }}:v${{ steps.version.outputs.value }} .