Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI workflow: Updated obsolete method set-output. #2824

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/auto-version-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
exit 1
fi
chart_path=$( ls chart-package/*.tgz )
echo ::set-output name=chart_path::${chart_path}
echo "chart_path=${chart_path}" >> $GITHUB_ENV
# ========== changelog
if ! ls changelog-result/*.md &>/dev/null ; then
echo "error, failed to find changelog "
Expand All @@ -153,7 +153,7 @@ jobs:
cat changelog-result/*.md
changelog_file=$( ls changelog-result/ )
changelog_path=./changelog-result/${changelog_file}
echo ::set-output name=changelog_path::${changelog_path}
echo "changelog_path=${changelog_path}" >> $GITHUB_ENV
cp ./changelog-result/${changelog_file} ./changelog-result/changelog.md

- name: Create Release
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/build-image-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,49 +63,49 @@ jobs:
if ${{ github.event_name == 'workflow_dispatch' }}; then
ref=${{ github.event.inputs.ref }}
echo "use re $ref , by workflow_dispatch"
echo ::set-output name=event_ref::${ref}
echo "event_ref=${ref}" >> $GITHUB_ENV
else
#trigger by pr
echo "use sha ${{ github.event.pull_request.head.sha }} , by pr"
echo ::set-output name=event_ref::${{ github.event.pull_request.head.sha }}
echo "event_ref=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
fi

- name: Checkout Source Code
uses: actions/checkout@v4
with:
persist-credentials: false
# fetch-depth: 0
ref: ${{ steps.get_event_version.outputs.event_ref }}
ref: ${{ env.event_ref }}

# after checkout code , could get the commit id of path ./images/baseimage , used for base image tag
- name: Generating Base Image Tag
id: base_tag
run: |
echo ::set-output name=tag::"$(git ls-tree --full-tree HEAD -- ./${{ env.IMAGE_ROOT_PATH }}/${{ env.IMAGE_NAME }} | awk '{ print $3 }')"
echo "tag=$(git ls-tree --full-tree HEAD -- ./${{ env.IMAGE_ROOT_PATH }}/${{ env.IMAGE_NAME }} | awk '{ print $3 }')" >> $GITHUB_ENV

# check whether we have upload the same base image to online register , if so, we could not build it
- name: Checking if tag already exists
id: tag-in-repositories
shell: bash
run: |
if docker buildx imagetools inspect ${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ steps.base_tag.outputs.tag }} &>/dev/null; then
echo ::set-output name=exists::"true"
echo "exists=true" >> $GITHUB_ENV
echo "the target base image exist , no need to build it "
else
echo ::set-output name=exists::"false"
echo "exists=false" >> $GITHUB_ENV
echo "the target base image does not exist , build it "
fi

- name: Login to online register
if: ${{ steps.tag-in-repositories.outputs.exists == 'false' }}
if: ${{ env.exists == 'false' }}
uses: docker/login-action@v3.0.0
with:
username: ${{ env.ONLINE_REGISTER_USER }}
password: ${{ env.ONLINE_REGISTER_PASSWORD }}
registry: ${{ env.ONLINE_REGISTER }}

- name: Release build ${{ env.IMAGE_NAME }}
if: ${{ steps.tag-in-repositories.outputs.exists == 'false' }}
if: ${{ env.exists == 'false' }}
uses: docker/build-push-action@v5.1.0
continue-on-error: false
id: docker_build_release
Expand All @@ -120,7 +120,7 @@ jobs:
${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ steps.base_tag.outputs.tag }}

- name: Image Release Digest
if: ${{ steps.tag-in-repositories.outputs.exists == 'false' }}
if: ${{ env.exists == 'false' }}
shell: bash
run: |
mkdir -p image-digest/
Expand All @@ -130,7 +130,7 @@ jobs:
echo "" >> image-digest/${{ env.IMAGE_NAME }}.txt

- name: Upload artifact digests
if: ${{ steps.tag-in-repositories.outputs.exists == 'false' }}
if: ${{ env.exists == 'false' }}
uses: actions/upload-artifact@v4.0.0
with:
name: image-digest ${{ env.IMAGE_NAME }}
Expand Down
78 changes: 39 additions & 39 deletions .github/workflows/build-image-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
# run if filters.src was changed
outputs:
imageTag: ${{ steps.tag.outputs.tag }}
imageTag: ${{ env.tag }}
e2e: ${{ steps.tag.outputs.e2e }}
strategy:
matrix:
Expand All @@ -61,29 +61,29 @@ jobs:
echo ${{ github.event_name }}
if ${{ inputs.ref != '' }}; then
echo "trigger by workflow_call"
echo ::set-output name=tag::${{ inputs.ref }}
echo ::set-output name=push::${{ inputs.push }}
echo "tag=${{ inputs.ref }}" >> $GITHUB_ENV
echo "push=${{ inputs.push }}" >> $GITHUB_ENV
elif ${{ github.event_name == 'push' }} ; then
echo "trigger by push"
echo ::set-output name=tag::${{ github.sha }}
echo ::set-output name=push::false
echo "tag=${{ github.sha }}" >> $GITHUB_ENV
echo "push=false" >> $GITHUB_ENV
elif ${{ github.event_name == 'pull_request_target' }} ; then
echo "trigger by pull_request_target"
echo ::set-output name=tag::${{ github.event.pull_request.head.sha }}
echo ::set-output name=push::false
echo "tag=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "push=false" >> $GITHUB_ENV
elif ${{ github.event_name == 'workflow_run' }} ; then
echo "trigger by workflow_run"
echo ::set-output name=tag::main
echo ::set-output name=push::false
echo "tag=main" >> $GITHUB_ENV
echo "push=false" >> $GITHUB_ENV
else
echo "trigger by ${{ github.event_name }}"
echo ::set-output name=tag::${{ github.sha }}
echo ::set-output name=push::false
echo "tag=${{ github.sha }}" >> $GITHUB_ENV
echo "push=false" >> $GITHUB_ENV
fi

- name: Login to online register
uses: docker/login-action@v3.0.0
if: ${{ steps.tag.outputs.push == 'true' }}
if: ${{ env.push == 'true' }}
with:
username: ${{ env.ONLINE_REGISTER_USER }}
password: ${{ env.ONLINE_REGISTER_PASSWORD }}
Expand All @@ -94,16 +94,16 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ steps.tag.outputs.tag }}
ref: ${{ env.tag }}

- name: Getting Build Arg
id: arg
continue-on-error: false
run: |
GIT_COMMIT_VERSION=$( git show -s --format='format:%H')
GIT_COMMIT_TIME=$( git show -s --format='format:%aI')
echo ::set-output name=commitver::${GIT_COMMIT_VERSION}
echo ::set-output name=committime::${GIT_COMMIT_TIME}
echo "commitver=${GIT_COMMIT_VERSION}" >> $GITHUB_ENV
echo "committime=${GIT_COMMIT_TIME}" >> $GITHUB_ENV

# ============= get cache ===========
# Load Golang cache build from GitHub
Expand Down Expand Up @@ -153,16 +153,16 @@ jobs:
# Only push when the event name was a GitHub push, this is to avoid
# re-pushing the image tags when we only want to re-create the Golang
# docker cache after the workflow "Image CI Cache Cleaner" was terminated.
push: ${{ steps.tag.outputs.push }}
push: ${{ env.push }}
provenance: false
platforms: linux/amd64,linux/arm64
github-token: ${{ secrets.WELAN_PAT }}
tags: |
${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}
${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ env.tag }}
build-args: |
GIT_COMMIT_VERSION=${{ steps.arg.outputs.commitver }}
GIT_COMMIT_TIME=${{ steps.arg.outputs.committime }}
VERSION=${{ steps.tag.outputs.tag }}
GIT_COMMIT_VERSION=${{ env.commitver }}
GIT_COMMIT_TIME=${{ env.committime }}
VERSION=${{ env.tag }}

# build debug image who turn on race and deadlock detection
- name: CI race detection Build ${{ matrix.name }}
Expand All @@ -176,25 +176,25 @@ jobs:
# Only push when the event name was a GitHub push, this is to avoid
# re-pushing the image tags when we only want to re-create the Golang
# docker cache after the workflow "Image CI Cache Cleaner" was terminated.
push: ${{ steps.tag.outputs.push }}
push: ${{ env.push }}
platforms: linux/amd64
outputs: type=tar,dest=/tmp/${{ matrix.name }}-race.tar
github-token: ${{ secrets.WELAN_PAT }}
tags: |
${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}-race
${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ env.tag }}-race
build-args: |
RACE=1
GIT_COMMIT_VERSION=${{ steps.arg.outputs.commitver }}
GIT_COMMIT_TIME=${{ steps.arg.outputs.committime }}
VERSION=${{ steps.tag.outputs.tag }}
GIT_COMMIT_VERSION=${{ env.commitver }}
GIT_COMMIT_TIME=${{ env.committime }}
VERSION=${{ env.tag }}

- name: CI Image Releases digests
if: ${{ github.event_name != 'pull_request_target' }}
shell: bash
run: |
mkdir -p image-digest/
echo "${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}@${{ steps.docker_build_ci_master.outputs.digest }}" > image-digest/${{ matrix.name }}.txt
echo "${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}-race@${{ steps.docker_build_ci_master_detect_race_condition.outputs.digest }}" >> image-digest/${{ matrix.name }}.txt
echo "${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ env.tag }}@${{ steps.docker_build_ci_master.outputs.digest }}" > image-digest/${{ matrix.name }}.txt
echo "${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ env.tag }}-race@${{ steps.docker_build_ci_master_detect_race_condition.outputs.digest }}" >> image-digest/${{ matrix.name }}.txt

# =========== trigger by PR updates , build 2 images
- name: CI Build ${{ matrix.name }}
Expand All @@ -205,16 +205,16 @@ jobs:
with:
context: .
file: ${{ matrix.dockerfile }}
push: ${{ steps.tag.outputs.push }}
push: ${{ env.push }}
provenance: false
github-token: ${{ secrets.WELAN_PAT }}
platforms: linux/amd64,linux/arm64
tags: |
${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}
${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ env.tag }}
build-args: |
GIT_COMMIT_VERSION=${{ steps.arg.outputs.commitver }}
GIT_COMMIT_TIME=${{ steps.arg.outputs.committime }}
VERSION=${{ steps.tag.outputs.tag }}
GIT_COMMIT_VERSION=${{ env.commitver }}
GIT_COMMIT_TIME=${{ env.committime }}
VERSION=${{ env.tag }}

- name: CI race detection Build ${{ matrix.name }}
if: ${{ github.event_name == 'pull_request_target' }}
Expand All @@ -224,25 +224,25 @@ jobs:
with:
context: .
file: ${{ matrix.dockerfile }}
push: ${{ steps.tag.outputs.push }}
push: ${{ env.push }}
platforms: linux/amd64
github-token: ${{ secrets.WELAN_PAT }}
outputs: type=tar,dest=/tmp/${{ matrix.name }}-race.tar
tags: |
${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}-race
${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ env.tag }}-race
build-args: |
RACE=1
GIT_COMMIT_VERSION=${{ steps.arg.outputs.commitver }}
GIT_COMMIT_TIME=${{ steps.arg.outputs.committime }}
VERSION=${{ steps.tag.outputs.tag }}
GIT_COMMIT_VERSION=${{ env.commitver }}
GIT_COMMIT_TIME=${{ env.committime }}
VERSION=${{ env.tag }}

- name: CI Image Releases digests
if: ${{ github.event_name == 'pull_request_target' }}
shell: bash
run: |
mkdir -p image-digest/
echo "${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}@${{ steps.docker_build_ci_pr.outputs.digest }}" > image-digest/${{ matrix.name }}.txt
echo "${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}-race@${{ steps.docker_build_ci_pr_detect_race_condition.outputs.digest }}" >> image-digest/${{ matrix.name }}.txt
echo "${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ env.tag }}@${{ steps.docker_build_ci_pr.outputs.digest }}" > image-digest/${{ matrix.name }}.txt
echo "${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}-ci:${{ env.tag }}-race@${{ steps.docker_build_ci_pr_detect_race_condition.outputs.digest }}" >> image-digest/${{ matrix.name }}.txt

# Upload artifact digests
- name: Upload artifact digests
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build-image-plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,23 @@ jobs:
shell: bash
run: |
if docker buildx imagetools inspect ${{ env.ONLINE_REGISTER }}/${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ steps.get_event_version.outputs.event_tag }} &>/dev/null; then
echo ::set-output name=exists::"true"
echo "exists=true" >> $GITHUB_ENV
echo "the target base image exist , no need to build it "
else
echo ::set-output name=exists::"false"
echo "exists=false" >> $GITHUB_ENV
echo "the target base image does not exist , build it "
fi

- name: Login to online register
if: ${{ steps.tag-in-repositories.outputs.exists == 'false' }}
if: ${{ env.exists == 'false' }}
uses: docker/login-action@v3.0.0
with:
username: ${{ env.ONLINE_REGISTER_USER }}
password: ${{ env.ONLINE_REGISTER_PASSWORD }}
registry: ${{ env.ONLINE_REGISTER }}

- name: Release build ${{ env.IMAGE_NAME }}
if: ${{ steps.tag-in-repositories.outputs.exists == 'false' }}
if: ${{ env.exists == 'false' }}
uses: docker/build-push-action@v5.1.0
continue-on-error: false
id: docker_build_release
Expand All @@ -209,7 +209,7 @@ jobs:
IPOIB_VERSION=${{ steps.get_event_version.outputs.event_ipoib_version }}

- name: Image Release Digest
if: ${{ steps.tag-in-repositories.outputs.exists == 'false' }}
if: ${{ env == 'false' }}
shell: bash
run: |
mkdir -p image-digest/
Expand All @@ -219,7 +219,7 @@ jobs:
echo "" >> image-digest/${{ env.IMAGE_NAME }}.txt

- name: Upload artifact digests
if: ${{ steps.tag-in-repositories.outputs.exists == 'false' }}
if: ${{ env == 'false' }}
uses: actions/upload-artifact@v4.0.0
with:
name: image-digest ${{ env.IMAGE_NAME }}
Expand Down
44 changes: 22 additions & 22 deletions .github/workflows/call-clean-ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,47 +46,47 @@ jobs:
repo=${{ github.repository }}
# github_action_test
repo=${repo#*/}
echo ::set-output name=repo_name::${repo}
echo "repo_name=${repo}" >> $GITHUB_ENV
if ${{ inputs.image_name != '' }} ; then
echo "call by workflow_call"
echo ::set-output name=image_name::${{ inputs.image_name }}
echo ::set-output name=tag_regex::${{ github.event.inputs.tag_regex }}
echo ::set-output name=older_than::${{ inputs.older_than }}
echo ::set-output name=dry_run::false
echo ::set-output name=keep_last::0
echo "image_name=${{ inputs.image_name }}" >> $GITHUB_ENV
echo "tag_regex=${{ github.event.inputs.tag_regex }}" >> $GITHUB_ENV
echo "older_than=${{ inputs.older_than }}" >> $GITHUB_ENV
echo "dry_run=false" >> $GITHUB_ENV
echo "keep_last=0" >> $GITHUB_ENV
elif ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "call by workflow_dispatch"
echo ::set-output name=image_name::${{ github.event.inputs.image_name }}
echo ::set-output name=tag_regex::
echo ::set-output name=older_than::${{ github.event.inputs.older_than }}
echo ::set-output name=dry_run::${{ github.event.inputs.dry_run }}
echo ::set-output name=keep_last::${{ github.event.inputs.keep_last }}
echo "image_name=${{ github.event.inputs.image_name }}" >> $GITHUB_ENV
echo "tag_regex=" >> $GITHUB_ENV
echo "older_than=${{ github.event.inputs.older_than }}" >> $GITHUB_ENV
echo "dry_run=${{ github.event.inputs.dry_run }}" >> $GITHUB_ENV
echo "keep_last=${{ github.event.inputs.keep_last }}" >> $GITHUB_ENV
else
echo "unexpected event: ${{ github.event_name }}"
exit 1
fi

- name: Delete CI image
if: ${{ steps.args.outputs.tag_regex != '' }}
if: ${{ env.tag_regex != '' }}
uses: vlaurin/action-ghcr-prune@v0.5.0
with:
token: ${{ secrets.WELAN_PAT }}
organization: ${{ github.repository_owner }}
container: ${{ steps.args.outputs.repo_name }}/${{ steps.args.outputs.image_name }}
dry-run: ${{ steps.args.outputs.dry_run }}
older-than: ${{ steps.args.outputs.older_than }}
keep-last: ${{ steps.args.outputs.keep_last }}
container: ${{ env.repo_name }}/${{ env.image_name }}
dry-run: ${{ env.dry_run }}
older-than: ${{ env.older_than }}
keep-last: ${{ env.keep_last }}
untagged: true
tag-regex: ${{ steps.args.outputs.tag_regex }}
tag-regex: ${{ env.tag_regex }}

- name: Delete CI image
if: ${{ steps.args.outputs.tag_regex == '' }}
if: ${{ env.tag_regex == '' }}
uses: vlaurin/action-ghcr-prune@v0.5.0
with:
token: ${{ secrets.WELAN_PAT }}
organization: ${{ github.repository_owner }}
container: ${{ steps.args.outputs.repo_name }}/${{ steps.args.outputs.image_name }}
dry-run: ${{ steps.args.outputs.dry_run }}
older-than: ${{ steps.args.outputs.older_than }}
keep-last: ${{ steps.args.outputs.keep_last }}
container: ${{ env.repo_name }}/${{ env.image_name }}
dry-run: ${{ env.dry_run }}
older-than: ${{ env.older_than }}
keep-last: ${{ env.keep_last }}
untagged: true
Loading
Loading