Skip to content

Commit

Permalink
Separate three images
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyzlj committed Oct 10, 2024
1 parent b558288 commit da6420f
Showing 1 changed file with 97 additions and 1 deletion.
98 changes: 97 additions & 1 deletion .github/workflows/Build_on_Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j 4

build-and-push-image:
deploy-alpine:
needs: build-linux
runs-on: ubuntu-22.04
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
Expand Down Expand Up @@ -117,6 +117,54 @@ jobs:
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.ALPINE_IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max

deploy-debian:
needs: build-linux
runs-on: ubuntu-22.04
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- uses: actions/checkout@v4
# login alibaba Container Registry
- name: Login to ACR
uses: aliyun/acr-login@v1
with:
login-server: ${{ env.LOGIN_SERVER }}
region-id: ${{ env.REGION_ID_ACR }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
# login ghcr.io
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_ACR }}/${{ env.NAMESPACE_ACR }}/${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
# https://github.com/marketplace/actions/docker-setup-buildx
- uses: docker/setup-buildx-action@v3
- name: Build based on debian
uses: docker/build-push-action@v5
with:
Expand All @@ -130,6 +178,54 @@ jobs:
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.DEBIAN_IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max

deploy-ubuntu:
needs: build-linux
runs-on: ubuntu-22.04
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- uses: actions/checkout@v4
# login alibaba Container Registry
- name: Login to ACR
uses: aliyun/acr-login@v1
with:
login-server: ${{ env.LOGIN_SERVER }}
region-id: ${{ env.REGION_ID_ACR }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
# login ghcr.io
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_ACR }}/${{ env.NAMESPACE_ACR }}/${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
# https://github.com/marketplace/actions/docker-setup-buildx
- uses: docker/setup-buildx-action@v3
- name: Build based on ubuntu
uses: docker/build-push-action@v5
with:
Expand Down

0 comments on commit da6420f

Please sign in to comment.