-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- introduce conventional commits - push patch and version series tags onto dockerhub
- Loading branch information
Showing
1 changed file
with
105 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,120 @@ | ||
name: docker-ci | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
paths-ignore: | ||
- '**/README.md' | ||
- main | ||
pull_request: | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
pull-requests: write | ||
|
||
jobs: | ||
docker: | ||
|
||
changelog: | ||
name: Changelog | ||
if: github.event_name != 'pull_request' | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
skipped: ${{ steps.changelog.outputs.skipped }} | ||
tag: ${{ steps.changelog.outputs.tag }} | ||
clean_changelog: ${{ steps.changelog.outputs.clean_changelog }} | ||
version: ${{ steps.changelog.outputs.version }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Conventional Changelog Action | ||
id: changelog | ||
uses: TriPSs/conventional-changelog-action@v5 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v2 | ||
if: ${{ steps.changelog.outputs.skipped == 'false' }} | ||
with: | ||
name: ${{ steps.changelog.outputs.tag }} | ||
tag_name: ${{ steps.changelog.outputs.tag }} | ||
body: ${{ steps.changelog.outputs.clean_changelog }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
deploy: | ||
name: Deploy Image | ||
needs: changelog | ||
if: github.event_name != 'pull_request' && needs.changelog.outputs.skipped == 'false' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- | ||
name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
- name: Get repository name | ||
id: get_repo | ||
run: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2 | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
|
||
- name: Checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
|
||
- name: Login to Dockerhub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v2 | ||
|
||
- name: Extract version parts | ||
id: extract_version | ||
run: | | ||
VERSION=${{ needs.changelog.outputs.version }} | ||
MAJOR_MINOR=$(echo $VERSION | cut -d'.' -f1,2) | ||
echo "MAJOR_MINOR_TAG=${MAJOR_MINOR}.x" >> $GITHUB_ENV | ||
- name: Setup Docker Metadata | ||
uses: docker/metadata-action@v5 | ||
id: meta | ||
with: | ||
images: | | ||
docker.io/${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.REPO_NAME }} | ||
tags: | | ||
latest | ||
${{ needs.changelog.outputs.version }} | ||
${{ github.sha }} | ||
${{ env.MAJOR_MINOR_TAG }} | ||
- name: Build and Push Docker Image | ||
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: l4rm4nd/dehasheddumper:latest | ||
platforms: linux/amd64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
release: | ||
name: Release | ||
needs: changelog | ||
if: github.event_name != 'pull_request' && needs.changelog.outputs.skipped == 'false' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
|
||
- name: Debug Changelog Outputs | ||
run: echo ${{ needs.changelog.outputs.tag }} | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag_name: ${{ needs.changelog.outputs.tag }} | ||
prerelease: false | ||
draft: false | ||
generate_release_notes: true | ||
name: ${{ needs.changelog.outputs.tag }} | ||
body: | | ||
<details> | ||
<summary>🤖 Autogenerated Conventional Changelog</summary> | ||
${{ needs.changelog.outputs.clean_changelog }} | ||
</details> |