Skip to content

Commit

Permalink
Merge pull request #245 from SuperChen-CC/cc-dev
Browse files Browse the repository at this point in the history
update: publish to ghrc.io action
  • Loading branch information
cyberchen1995 authored Jan 4, 2024
2 parents 983debd + a2eab6c commit aa81e92
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ jobs:
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64, 386, loong64]
goarch: [amd64, arm64, 386]
# goarch: [amd64, arm64, 386, loong64]
exclude:
- goarch: arm64
goos: windows
- goarch: 386
goos: darwin
- goarch: 386
goos: windows
- goarch: loong64
goos: windows
- goarch: loong64
goos: darwin
# - goarch: loong64
# goos: windows
# - goarch: loong64
# goos: darwin
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -66,5 +67,6 @@ jobs:
project_path: "./"
binary_name: opensca-cli
sha256sum: true
md5sum: false
extra_files: README.md config.json db-demo.json VERSION
ldflags: "-s -w -X 'main.version=${{ env.RELEASE_VERSION }}' "
61 changes: 32 additions & 29 deletions .github/workflows/publish_docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to build'
description: "Tag to build"
required: true
log_level:
description: 'Log level'
description: "Log level"
required: false
default: 'info'

default: "info"

jobs:
publish-to-dockerhub:
Expand Down Expand Up @@ -45,30 +44,34 @@ jobs:
tags: ${{ secrets.DOCKERHUB_USERNAME }}/opensca-cli:latest, ${{ secrets.DOCKERHUB_USERNAME }}/opensca-cli:${{ env.VERSION }}

publish-to-github:
name: Publish to GitHub
name: Publish to Github
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Convert to lowercase
run: |
echo "LATEST_TAG=ghcr.io/${{ github.repository }}/opensca-cli:latest" | tr '[:upper:]' '[:lower:]' >> ${GITHUB_ENV}
echo "VERSION_TAG=ghcr.io/${{ github.repository }}/opensca-cli:${{ env.VERSION }}" | tr '[:upper:]' '[:lower:]' >> ${GITHUB_ENV}
- name: Print env variables
run: |
echo "LATEST_TAG=${{ env.LATEST_TAG }}"
echo "VERSION_TAG=${{ env.VERSION_TAG }}"
- name: Build and push to GitHub Packages
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
VERSION=${{ env.VERSION }}
tags: ${{ env.LATEST_TAG }}, ${{ env.VERSION_TAG }}
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set VERSION ENV
run: echo VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) >> ${GITHUB_ENV}
- name: Convert to lowercase
run: |
echo latest_tag=ghcr.io/${{ github.repository_owner }}/opensca-cli:latest | tr '[:upper:]' '[:lower:]' >> ${GITHUB_ENV}
echo version_tag=ghcr.io/${{ github.repository_owner }}/opensca-cli:${{ env.VERSION }} | tr '[:upper:]' '[:lower:]' >> ${GITHUB_ENV}
- name: Build and push to GitHub Packages
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
VERSION=${{ env.VERSION }}
tags: ${{ env.latest_tag }}, ${{ env.version_tag }}

0 comments on commit aa81e92

Please sign in to comment.