Skip to content

Commit

Permalink
chore: Unify user focused Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
cybersokari committed Dec 29, 2024
1 parent 1a0037c commit 9299b25
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 157 deletions.
28 changes: 1 addition & 27 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
- major
default: patch
build-docker:
description: Release companion Docker and Action Docker images
description: Release companion Docker image
type: boolean
default: true

Expand Down Expand Up @@ -71,32 +71,6 @@ jobs:
push: 'origin main --force'
tag: 'v${{steps.publish.outputs.version}} --force'

deploy-docker-action:
if: ${{ github.event.inputs.job == 'cli' && github.event.inputs.build-docker }}
runs-on: ubuntu-latest
needs: deploy-cli
env:
DIR: apps/action
steps:
- uses: actions/[email protected]
- name: Docker login
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/[email protected]
with:
context: ${{env.DIR}}
file: ${{env.DIR}}/action.Dockerfile
platforms: linux/amd64
push: true
build-args: CLI_VERSION=${{needs.deploy-cli.outputs.version}}
tags: |
sokari/allure-deployer-action:${{needs.deploy-cli.outputs.version}}
sokari/allure-deployer-action:${{ github.sha }}
deploy-docker:
if: ${{ github.event.inputs.job == 'cli' && github.event.inputs.build-docker }}
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
steps:
- uses: actions/[email protected]
- name: Allure Deployer Action
uses: ./apps/action
uses: ./apps/docker
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
SLACK_TOKEN: ${{secrets.SLACK_TOKEN}}
Expand Down
12 changes: 0 additions & 12 deletions apps/action/action.Dockerfile

This file was deleted.

44 changes: 0 additions & 44 deletions apps/action/entrypoint.sh

This file was deleted.

23 changes: 0 additions & 23 deletions apps/cli/test.Dockerfile

This file was deleted.

6 changes: 3 additions & 3 deletions apps/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM deps AS prod

ARG CLI_VERSION
RUN npm i -g allure-deployer@$CLI_VERSION
COPY start.sh /start.sh
RUN chmod +x /start.sh
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/start.sh"]
ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion apps/action/action.yaml → apps/docker/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: 'Deploy Allure Reports as a website, with unique Ephemeral URLs per
author: 'Sokari Gillis-Harry'
runs:
using: 'docker'
image: 'docker://sokari/act-github-actions-dockeraction:latest'
image: 'test.Dockerfile'
# image: 'docker://sokari/allure-deployer-action:latest'
args:
- storage_bucket=${{ inputs.storage_bucket }}
Expand Down
63 changes: 63 additions & 0 deletions apps/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh

# Exit immediately if a command exits with a non-zero status
set -e

GOOGLE_APPLICATION_CREDENTIALS="/credentials/key.json"
if [ -f "$GOOGLE_APPLICATION_CREDENTIALS" ]; then
# Running as an bare container
export GOOGLE_APPLICATION_CREDENTIALS
ALLURE_RESULTS_PATH="/allure-results"
# Check if /allure-results directory is mounted
if [ ! -d "$ALLURE_RESULTS_PATH" ]; then
echo "Error: $ALLURE_RESULTS_PATH directory is not mounted"
exit 1
fi

elif [ -d "/github/workspace" ]; then
#Running as a GitHub Action container
if [ -z "$GOOGLE_CREDENTIALS_JSON" ]; then
echo "Error: Provide a Firebase Google JSON credential "
exit 1
else
# Create directory for the JSON file
DIR="/credentials"
mkdir -p DIR
JSON_FILE="$DIR/key.json"
# Write the $GOOGLE_CREDENTIALS_JSON content to the JSON file
echo "$GOOGLE_CREDENTIALS_JSON" > "$JSON_FILE" # No cleanup needed, in non mounted Docker path
# Export as GOOGLE_APPLICATION_CREDENTIALS for Firebase CLI auto auth
export GOOGLE_APPLICATION_CREDENTIALS="$JSON_FILE"
fi

# Create variables by stripping "key=" and keeping only the value from
# GitHub action arguments
STORAGE_BUCKET="${1#*=}"
REPORT_NAME="${2#*=}"
SLACK_CHANNEL="${3#*=}"
ALLURE_RESULTS_PATH="${4#*=}"
SHOW_RETRIES="${5#*=}"
SHOW_HISTORY="${6#*=}"
PREFIX="${7#*=}"
UPDATE_PR="${8#*=}"
else
echo "Error: No credential file exists at $GOOGLE_APPLICATION_CREDENTIALS. Please mount a Firebase Google JSON file"
exit 1
fi

# Construct the command with all optional variables
deploy_command="allure-deployer deploy \"$ALLURE_RESULTS_PATH\""

[ -n "$REPORT_NAME" ] && deploy_command="$deploy_command $REPORT_NAME"
[ -n "$GOOGLE_APPLICATION_CREDENTIALS" ] && deploy_command="$deploy_command --gcp-json $GOOGLE_APPLICATION_CREDENTIALS"
[ -n "$STORAGE_BUCKET" ] && deploy_command="$deploy_command --bucket $STORAGE_BUCKET"
[ "$SHOW_RETRIES" = "true" ] && deploy_command="$deploy_command --show-retries"
[ "$SHOW_HISTORY" = "true" ] && deploy_command="$deploy_command --show-history"
[ -n "$SLACK_CHANNEL" ] && deploy_command="$deploy_command --slack-channel $SLACK_CHANNEL"
[ -n "$SLACK_TOKEN" ] && deploy_command="$deploy_command --slack-token $SLACK_TOKEN"
[ -n "$PREFIX" ] && deploy_command="$deploy_command --prefix $PREFIX"
[ -n "$UPDATE_PR" ] && deploy_command="$deploy_command --update-pr $UPDATE_PR"

# Execute the constructed command
eval "$deploy_command"
#tail -f /dev/null
44 changes: 0 additions & 44 deletions apps/docker/start.sh

This file was deleted.

2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ services:
STORAGE_BUCKET: $GCP_BUCKET
PREFIX: 'project-999'
REPORT_NAME: 'Demo Report 1'
KEEP_HISTORY: true # Default is true when STORAGE_BUCKET is provided
KEEP_RESULTS: false # Default is false
SHOW_HISTORY: false
SHOW_RETRIES: false
volumes:
Expand Down
30 changes: 30 additions & 0 deletions test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This image npm pack the CLI for testing
FROM node:20-alpine AS javanode
RUN apk add openjdk17-jre

FROM node:20-alpine AS build
WORKDIR /app
ENV CLI_DIR=/apps/cli
COPY $CLI_DIR/src src
COPY $CLI_DIR/package*.json /app/
COPY $CLI_DIR/tsconfig.json .
COPY $CLI_DIR/version-update.cjs .

RUN npm install
RUN npm run build
RUN npm publish --dry-run
RUN npm pack
RUN mv allure-deployer*.tgz allure-deployer.tgz

FROM javanode AS install
COPY --from=build /app/allure-deployer.tgz allure-deployer.tgz

RUN npm i -g allure-deployer.tgz

RUN allure-deployer -V

COPY apps/docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

0 comments on commit 9299b25

Please sign in to comment.