Build Docker image and push to dockerhub #36
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: Build Docker image and push to dockerhub | |
on: | |
workflow_run: | |
workflows: ["Deriv App Staging Workflow"] | |
types: [completed] | |
workflow_dispatch: | |
inputs: | |
docker_image_tag_name: | |
type: string | |
description: Docker image tag name | |
required: true | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
env: | |
tag_name: ${{ github.event.inputs.docker_image_tag_name || github.ref_name }} | |
permissions: | |
packages: write | |
contents: read | |
attestations: write | |
id-token: write | |
environment: Staging | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Convert branch name to lowercase | |
id: branch_name | |
run: | | |
branch_name="$tag_name" | |
echo "image_name=${branch_name,,}" >> "$GITHUB_OUTPUT" | |
- name: Log in to Docker Hub | |
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | |
with: | |
username: ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }} | |
password: ${{ secrets.WEB_ACCESS_DOCKERHUB_PASSWORD }} | |
- name: Run Bootstrap | |
run: npm run bootstrap | |
- name: Run Build:prod | |
uses: "./.github/actions/build" | |
with: | |
NODE_ENV: staging | |
CROWDIN_WALLETS_API_KEY: ${{ secrets.CROWDIN_WALLETS_API_KEY }} | |
DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }} | |
DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }} | |
IS_GROWTHBOOK_ENABLED: ${{ vars.IS_GROWTHBOOK_ENABLED }} | |
DATADOG_CLIENT_TOKEN_LOGS: ${{ vars.DATADOG_CLIENT_TOKEN_LOGS }} | |
DATADOG_SESSION_REPLAY_SAMPLE_RATE: ${{ vars.DATADOG_SESSION_REPLAY_SAMPLE_RATE }} | |
DATADOG_SESSION_SAMPLE_RATE: ${{ vars.DATADOG_SESSION_SAMPLE_RATE }} | |
DATADOG_SESSION_SAMPLE_RATE_LOGS: ${{ vars.DATADOG_SESSION_SAMPLE_RATE_LOGS }} | |
GD_API_KEY: ${{ secrets.GD_API_KEY }} | |
GD_APP_ID: ${{ secrets.GD_APP_ID }} | |
GD_CLIENT_ID: ${{ secrets.GD_CLIENT_ID }} | |
RUDDERSTACK_KEY: ${{ vars.RUDDERSTACK_KEY }} | |
GROWTHBOOK_CLIENT_KEY: ${{ vars.GROWTHBOOK_CLIENT_KEY }} | |
GROWTHBOOK_DECRYPTION_KEY: ${{ vars.GROWTHBOOK_DECRYPTION_KEY }} | |
REF_NAME: ${{ github.ref_name }} | |
REMOTE_CONFIG_URL: ${{ vars.REMOTE_CONFIG_URL }} | |
TRUSTPILOT_API_KEY: ${{ secrets.TRUSTPILOT_API_KEY }} | |
- name: Run Build Docker | |
env: | |
IMAGE_NAME: ${{ steps.branch_name.outputs.image_name }} | |
run: docker build -t ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/$IMAGE_NAME . --platform=linux/amd64 | |
- name: Run Tag Docker | |
env: | |
IMAGE_NAME: ${{ steps.branch_name.outputs.image_name }} | |
run: docker tag ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/$IMAGE_NAME ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/$IMAGE_NAME | |
- name: Run Push Docker | |
env: | |
IMAGE_NAME: ${{ steps.branch_name.outputs.image_name }} | |
run: docker push ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/$IMAGE_NAME |