Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
ci: add new release action
Browse files Browse the repository at this point in the history
  • Loading branch information
Divkix committed Sep 6, 2022
1 parent 15f2df8 commit 83f3364
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 92 deletions.
69 changes: 0 additions & 69 deletions .github/workflows/docker-build.yml

This file was deleted.

136 changes: 136 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Release

on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release'
required: true

env:
ProjectName: vidmergebot

jobs:
# only run this step when the tag is not already created
create-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create and Push Tag
if: startsWith(github.ref, 'refs/tags/') != 'true' && github.event.inputs.tag != ''
run: |-
git config --global user.email "[email protected]"
git config --global user.name "Divanshu Chauhan"
tag=${{ github.event.inputs.tag }} # if triggered by workflow_dispatch
if [ -z "$tag" ]; then
tag=${GITHUB_REF#refs/tags/}
fi
git tag -f -a -m "$tag" "$tag"
git push -f origin "$tag"
# build the docker image and push it to docker hub and ghcr
docker-build:
name: Build Image
needs: create-tag
runs-on: ubuntu-latest

steps:
- name: Checkout current repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set ENV Variables
id: vars
run: |
IMG="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')"
TAG="$(git tag | sort -V | tail -1)"
echo "BUILD_VER=${TAG}" >> $GITHUB_ENV
echo "::set-output name=tag::${TAG}"
echo "IMAGE=${IMG}" >> $GITHUB_ENV
echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
echo "GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ env.IMAGE }}:latest
ghcr.io/${{ env.IMAGE }}:${{ env.BUILD_VER }}
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ env.BUILD_VER }}
labels: |
org.opencontainers.image.authors=${{ github.repository_owner }}
org.opencontainers.image.created=${{ env.BUILD_DATE }}
org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA }} and ref ${{ env.GIT_REF }}
org.opencontainers.image.ref.name=${{ env.GIT_REF }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ env.BUILD_VER }}
outputs:
BUILD_VER: ${{ steps.vars.outputs.tag }}

# update description of the docker image on docker hub
update-dockerhub-description:
name: Update Description
needs: create-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

# create a release on github
release:
name: Release
runs-on: ubuntu-latest
needs:
- docker-build
- create-tag
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.docker-build.outputs.BUILD_VER }}
tag_name: ${{ needs.docker-build.outputs.BUILD_VER }}
body: |-
${{ github.event.repository.name }} ${{ needs.docker-build.outputs.BUILD_VER }}
Docker Images:
`ghcr.io/${{ github.repository_owner }}/${{ env.ProjectName }}:${{ needs.docker-build.outputs.BUILD_VER }}`
`docker.io/${{ github.repository_owner }}/${{ env.ProjectName }}:${{ needs.docker-build.outputs.BUILD_VER }}`
23 changes: 0 additions & 23 deletions .github/workflows/update-docker-readme.yml

This file was deleted.

0 comments on commit 83f3364

Please sign in to comment.