From 09a1d27aa52d220684bcc6d70d2b26c8cceeba21 Mon Sep 17 00:00:00 2001 From: Georgy Malkov Date: Tue, 24 Oct 2023 19:15:20 +0300 Subject: [PATCH 1/2] add ci build application docker --- .../workflows/build_application_docker.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/build_application_docker.yaml diff --git a/.github/workflows/build_application_docker.yaml b/.github/workflows/build_application_docker.yaml new file mode 100644 index 0000000..576cf38 --- /dev/null +++ b/.github/workflows/build_application_docker.yaml @@ -0,0 +1,54 @@ +on: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +name: Build Application Docker + +env: + REGISTRY: ghcr.io + IMAGE_NAME: gravity-ui/node-nginx + IMAGE_OS_NODE_VERSION: ubuntu20-nodejs18 + +jobs: + build: + name: docker-nodejs + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - name: 'Get release build date' + run: | + BUILD_DATE=$(date -I) + echo "Release build date: ${BUILD_DATE}" + echo "BUILD_DATE=$BUILD_DATE" >> "$GITHUB_ENV" + - name: Log in to the Container registry + uses: docker/login-action@v3.0.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract tags for Docker + id: meta + uses: docker/metadata-action@v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=${{ env.IMAGE_OS_NODE_VERSION }} + type=raw,value=${{ env.IMAGE_OS_NODE_VERSION }}.${{ env.BUILD_DATE }} + - name: Build and push Docker image + uses: docker/build-push-action@v5.0.0 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max From 473558bb7407f7d2d3735688a2f74bde4f687440 Mon Sep 17 00:00:00 2001 From: Georgy Malkov Date: Tue, 24 Oct 2023 19:25:03 +0300 Subject: [PATCH 2/2] fix build version tag from commit --- .github/workflows/build_application_docker.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_application_docker.yaml b/.github/workflows/build_application_docker.yaml index 576cf38..9b65894 100644 --- a/.github/workflows/build_application_docker.yaml +++ b/.github/workflows/build_application_docker.yaml @@ -1,7 +1,5 @@ on: - push: - branches: - - main + workflow_dispatch: concurrency: group: ${{ github.workflow }} @@ -26,7 +24,7 @@ jobs: - uses: docker/setup-buildx-action@v3 - name: 'Get release build date' run: | - BUILD_DATE=$(date -I) + BUILD_DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d) echo "Release build date: ${BUILD_DATE}" echo "BUILD_DATE=$BUILD_DATE" >> "$GITHUB_ENV" - name: Log in to the Container registry