Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-4535] rework docker publishing actions #3068

Merged
merged 3 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/get-image-tag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Get Image Tag"
description: "Generates a tag for Docker image"

inputs:
branch_name:
description: 'Name of the branch the workflow runs on'
required: true
type: string

runs:
using: "composite"
steps:
- name: Get docker image tag name
shell: bash
run: |
if [[ "${{ inputs.branch_name }}" == "master" ]]; then
TAG_VERSION="$(jq -cr '.version' < package.json)"
else
TAG_VERSION="${{ inputs.branch_name }}-${{ github.run_id }},{{ inputs.branch_name }}"
fi
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
37 changes: 25 additions & 12 deletions .github/actions/publish-image/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "Publish Docker Images"
description: "Publish Docker image to quay.io or dockerhub or another domain - only publish the version on master - elsewhere version and branch"
description: "Publish Docker Image to the provided registry"

inputs:
domain:
description: 'domain to publish image to'
registry:
description: 'Docker registry'
required: true
type: string
username:
Expand All @@ -26,15 +26,28 @@ inputs:
runs:
using: "composite"
steps:
- name: Get docker image tag name
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- name: Get Tag
uses: ./.github/actions/get-image-tag
with:
branch_name: ${{ inputs.branch_name }}

- name: Publish
shell: bash
run: |
if [[ "${{ inputs.branch_name }}" == "master" ]]; then
TAG_VERSION=$(jq -cr '.version' < package.json)
else
TAG_VERSION=${{ inputs.branch_name }}-${{ github.run_id }}
if [[ "${{ inputs.dry-run }}" != "true" ]]; then
npm ci && npm run build.release
echo "Running the docker with tag $TAG_VERSION"

npx @alfresco/adf-cli docker-publish \
--dockerRepo "${{ inputs.registry }}/alfresco/alfresco-content-app" \
--buildArgs "PROJECT_NAME=content-ce" \
--dockerTags "$TAG_VERSION" \
--pathProject "$(pwd)"
fi
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
- name: Publish image
shell: bash
run: ./scripts/gh/docker-publish.sh "${{ inputs.domain }}" "$REPO_SLUG" "${{ inputs.username }}" "${{ inputs.password }}" "$TAG_VERSION" "${{ inputs.branch_name }}" "${{ inputs.dry-run }}"
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ env:
APP_CONFIG_OAUTH2_REDIRECT_LOGOUT: /
APP_CONFIG_OAUTH2_REDIRECT_LOGIN: /
APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI: "{protocol}//{hostname}{:port}/assets/silent-refresh.html"
REPO_SLUG: "alfresco/alfresco-content-app"
NPM_REGISTRY_ADDRESS: ${{ secrets.NPM_REGISTRY_ADDRESS }}


Expand All @@ -57,7 +56,7 @@ jobs:
uses: ./.github/actions/publish-image
with:
branch_name: ${{ env.BRANCH_NAME }}
domain: quay.io
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
dry-run: ${{ inputs.dry-run-release }}
Expand All @@ -80,7 +79,7 @@ jobs:
uses: ./.github/actions/publish-image
with:
branch_name: ${{ env.BRANCH_NAME }}
domain: docker.io
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dry-run: ${{ inputs.dry-run-release }}
Expand Down
26 changes: 0 additions & 26 deletions scripts/gh/docker-publish.sh

This file was deleted.