Merge pull request #38 from devgateway/task/DVIZ-24/admin-docker-opti… #13
This file contains hidden or 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: Generate a Pre-Release | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
pull-requests: write | |
packages: write | |
jobs: | |
prepare-a-release: | |
runs-on: ubuntu-latest | |
outputs: | |
new_version: ${{ steps.tag_version.outputs.new_version }} | |
new_tag: ${{ steps.tag_version.outputs.new_tag }} | |
current_date: ${{ steps.current_date.outputs.current_date }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Get Current Date And Time | |
id: current_date | |
run: echo "current_date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | |
- name: Generate Tag | |
id: tag_version | |
uses: mathieudutour/github-tag-action@v6.2 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag_prefix: 'v' | |
release_branches: 'production,release/*' | |
pre_release_branches: 'main' | |
append_to_pre_release_tag: 'snapshot-${{steps.current_date.outputs.current_date}}' | |
dry_run: 'true' | |
build-and-push-docker-image: | |
needs: prepare-a-release | |
runs-on: ubuntu-latest | |
outputs: | |
new_version: ${{ needs.prepare-a-release.outputs.new_version }} | |
new_tag: ${{ needs.prepare-a-release.outputs.new_tag }} | |
current_date: ${{ needs.prepare-a-release.outputs.current_date }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ vars.DOCKER_REGISTRY }} | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
cache-from: type=gha, scope=data-viz-admin | |
cache-to: type=gha, scope=data-viz-admin | |
context: . | |
push: true | |
build-args: | | |
VERSION=${{ needs.prepare-a-release.outputs.new_version }} | |
TAG=${{ needs.prepare-a-release.outputs.new_tag }} | |
tags: | | |
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:v${{ needs.prepare-a-release.outputs.new_version }} | |
release-on-github: | |
needs: build-and-push-docker-image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'corretto' | |
cache: 'maven' | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ needs.build-and-push-docker-image.outputs.new_tag }} | |
generate_release_notes: true | |
draft: false | |
prerelease: true | |
make_latest: 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |