--Github repository --Dockerfile in the repository
Create PAT from Github settings, location:
Github -> Settings -> Developer settings -> Personal access tokens
Privileges: Check write: packages`` read: packages
Click New Secrets
in Settings-> Secrets
in the repository:
CT_PAT
--Value: Token
created earlierdocker-publish.yml
name: Docker
on:
push:
# `master`Branch`latest`Build as
branches:
- master
#version`v1.2.3`Build with tag released
tags:
- v*
#Test if you have a PR
pull_request:
env:
# TODO:The name of the Docker image
IMAGE_NAME: author/xxxx
jobs:
#test
#Commentary: https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
#Push the Docker image to GitHub Packages
#Commentary: https://docs.docker.com/docker-hub/builds/
push:
#Check the test
needs: test
runs-on: ubuntu-latest
#Run when not PR
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log into GitHub Container Registry
#I set it to Secrets here`CR_PAT`Using ghcr.Log in to io
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
#Make the name of the set Docker image lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
#Processing version characters
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
#From the tag"v"Remove
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
#If it's the master branch`latest`Tag
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
If you commit this file, it should automatically run once, the log will be visible under Actions in the repository. This Actions also supports docker-compose.
The actual application is Please refer to the OVaaS Front-End repository currently under development: https://github.com/OVaaS/ovaas-front
Recommended Posts