-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: refactor GitHub Actions and Docker build-push-action settings
- Add a new GitHub Actions workflow `docker-reused-setup-steps/action.yml` for setting up docker, which allows logging into DockerHub and GitHub Container Registry - The new workflow needs DockerHub organization name, DockerHub username, DockerHub token, and a tag as inputs and provides tags and labels as outputs - In the existing `docker_publish.yml` workflow, update the permissions provided to the GITHUB_TOKEN - Remove individual `Docker meta`, `Set up QEMU`, `Set up Docker Buildx`, and docker hub/registry login steps, and replace them with the newly created reusable docker setup action - Update the `Build and push` step to include build arguments for assigning the version and release number - Add caching to registry to avoid the GitHub Actions capacity limit, along with enabling of Software Bill of Materials (sbom) and Provenance - Extend the target platforms to include both linux/amd64 and linux/arm64. Signed-off-by: 陳鈞 <[email protected]>
- Loading branch information
Showing
2 changed files
with
83 additions
and
43 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Setup docker | ||
|
||
description: Configure the docker workflow. | ||
|
||
inputs: | ||
DOCKERHUB_ORGANIZATION_NAME : | ||
required: true | ||
DOCKERHUB_USERNAME: | ||
required: true | ||
DOCKERHUB_TOKEN: | ||
required: true | ||
tag: | ||
required: true | ||
|
||
outputs: | ||
tags: | ||
description: "tags" | ||
value: ${{ steps.meta.outputs.tags }} | ||
labels: | ||
description: "labels" | ||
value: ${{ steps.meta.outputs.labels }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Docker meta:${{ inputs.tag }} | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ inputs.DOCKERHUB_ORGANIZATION_NAME }}/azure-uploader,ghcr.io/${{ github.repository_owner }}/azure-uploader | ||
flavor: | | ||
latest=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | ||
prefix= | ||
suffix= | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# Create a Access Token and save it as as Actions secret | ||
# https://hub.docker.com/settings/security | ||
# DOCKERHUB_USERNAME | ||
# DOCKERHUB_TOKEN | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ inputs.DOCKERHUB_USERNAME }} | ||
password: ${{ inputs.DOCKERHUB_TOKEN }} | ||
|
||
# You may need to manage write and read access of GitHub Actions for repositories in the container settings. | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ github.token }} |
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