add resource list #76
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: Create and publish a Docker image to ghcr.io | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
docker: | |
name: build and push image to docker hub | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: prepare | |
id: prep | |
run: | | |
DOCKER_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | |
VERSION=latest | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
elif [[ $GITHUB_REF == refs/pull/* ]]; then | |
VERSION=pr-${{ github.event.number }} | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
#if [ "${{ github.event_name }}" = "push" ]; then | |
# TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" | |
#fi | |
echo ::set-output name=version::${VERSION} | |
echo ::set-output name=tags::${TAGS} | |
echo ::set-output name=current_time::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
echo ::set-output name=git_description::$(git describe --always --dirty --tags --long) | |
- name: Log in to the Container registry | |
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: buil and push | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./deploy/Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.prep.outputs.tags }} | |
build-args: | | |
current_time=${{ steps.prep.outputs.current_time }} | |
git_description=${{ steps.prep.outputs.git_description }} | |
- name: imge digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
- name: post to set-img webhook | |
shell: bash | |
env: | |
TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
URL: ${{ secrets.SET_IMG_URL }} | |
run: | | |
curl $URL \ | |
-X POST \ | |
-H "Authorization: $TOKEN" \ | |
--data-binary '{"namespace":"wu","kind": "deploy","name":"set-img","container_name":"img","img":"${{ steps.prep.outputs.tags }}"}' |