Skip to content

Merge pull request #2 from Abirdcfly/main #1

Merge pull request #2 from Abirdcfly/main

Merge pull request #2 from Abirdcfly/main #1

Workflow file for this run

name: Build image
on:
push:
branches: [main]
env:
REGISTRY: docker.io
IMAGE_NAME: yuntijs/gql-sdk-generator
DOCKER_USER: yuntijs
jobs:
image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Variable
id: set-env
run: |
TAG=$(git describe --tags --abbrev=0 --match 'v*' 2> /dev/null) || true
if [ -z "$TAG" ]; then
echo "No tag found, use v0.0.1 as default"
TAG=v0.0.1
fi
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
echo "DATE=$(TZ=Asia/Shanghai date +'%Y%m%d')" >> $GITHUB_OUTPUT
- name: Show Variable
run: echo "varibables ${{ steps.set-env.outputs.TAG }}-${{ steps.set-env.outputs.DATE }}"
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
config-inline: |
[worker.oci]
max-parallelism = 1
- name: Login to the dockerhub Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- uses: benjlevesque/[email protected]
name: Get short commit sha
id: short-sha
- name: setting token to npmrc
run: |
echo '//dev-npm.tenxcloud.net/:_authToken="${{ secrets.NPMTOKEN }}"' > /tmp/npmrc
- name: Build and push
id: push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.set-env.outputs.TAG }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.set-env.outputs.DATE }}-${{ steps.short-sha.outputs.sha }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.set-env.outputs.TAG }}-${{ steps.set-env.outputs.DATE }}-${{ steps.short-sha.outputs.sha }}
${{ steps.meta.outputs.tags }}
push: true
build-args: |
BUILD_ID=${{ env.SEMREV_LABEL }}
BUILD_DATE=${{ env.BUILD_DATE }}
secret-files: |
"npmrc=/tmp/npmrc"