Docker Image CI Release #4
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 | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get the latest tag | |
id: get_latest_tag | |
run: | | |
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "") | |
echo "latest_tag=$latest_tag" >> $GITHUB_ENV | |
- name: Checkout the latest tag if exists | |
run: git checkout ${{ env.latest_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=${{ env.latest_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}} | |
type=semver,pattern={{major}} | |
type=semver,pattern={{major}}.{{minor}} | |
- 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 }} | |