[workflows/ci-cd] Add CI/CD Workflow #21
Workflow file for this run
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
name: CI/CD | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- closed | |
- synchronize | |
- opened | |
workflow_dispatch: | |
env: | |
REGISTRY: docker.io | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set environment variables | |
run: | | |
SHA=${{ hashFiles('**/package-lock.json') }} | |
TAG=${SHA:0:10} | |
USER=$GITHUB_REPOSITORY_OWNER | |
BUILDER_STRING=${REGISTRY}/${GITHUB_REPOSITORY}:builder-${TAG} | |
CONTEXT="./" | |
echo "BUILDER_STRING=$BUILDER_STRING" >> $GITHUB_ENV | |
echo "USER=$USER >> $GITHUB_ENV" | |
echo "CONTEXT=$CONTEXT" >> $GITHUB_ENV | |
- name: Build builder image | |
run: | | |
echo $BUILDER_STRING | |
echo $USER | |
echo $CONTEXT | |
echo $(docker manifest inspect $BUILDER_STRING > /dev/null ; echo $?) | |
if docker manifest inspect $BUILDER_STRING >/dev/null; | |
then | |
exit 0 | |
fi | |
docker login -u=$USER -p=${{ secrets.DOCKER_CI_TOKEN }} docker.io | |
# docker buildx create --use --driver=docker-container | |
# docker buildx build --push -t $BUILDER_STRING \ | |
# --cache-from type=registry,ref=$BUILDER_STRING \ | |
# --cache-to type=registry,ref=$BUILDER_STRING \ | |
# ${CONTEXT} | |
# echo "Published image $BUILDER_STRING" | |
docker logout | |