Docker Image CI Release #18
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: Docker Image CI Release | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
schedule: | |
- cron: '0 4 * * 0' # This will run the workflow every Sunday at 4 am | |
workflow_dispatch: | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get the latest tag | |
uses: oprypin/find-latest-tag@v1 | |
with: | |
repository: wemove/read2burn # The repository to scan. | |
releases-only: false # We know that all relevant tags have a GitHub release for them. | |
regex: '^.+\.\d+\.\d+$' | |
sort-tags: false | |
id: read2burn # The step ID to refer to later. | |
- name: Checkout the latest tag if exists | |
run: | | |
git fetch --all --tags --prune | |
git checkout tags/${{ steps.read2burn.outputs.tag }} | |
- name: Get the commit ID | |
id: get_commit | |
run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
- name: Inject version and commit ID into index.ejs | |
run: | | |
VERSION=${{ steps.read2burn.outputs.tag }} | |
COMMIT=${{ env.commit }} | |
echo "<!-- Version: $VERSION, Commit ID: $COMMIT -->" >> views/index.ejs | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
wemove/read2burn | |
tags: | | |
type=semver,pattern={{version}},value=${{ steps.read2burn.outputs.tag }} | |
type=semver,pattern={{major}},value=${{ steps.read2burn.outputs.tag }} | |
type=semver,pattern={{major}}.{{minor}},value=${{ steps.read2burn.outputs.tag }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
file: docker/Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |