-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add publish docker image action
- Loading branch information
1 parent
4bf81f9
commit eed5de1
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Publish Docker image | ||
description: Reusable action to build and push docker images | ||
|
||
inputs: | ||
docker-image: | ||
description: 'Docker image name' | ||
required: true | ||
docker-password: | ||
description: 'Docker hub password' | ||
required: true | ||
docker-username: | ||
description: 'Docker hub username' | ||
required: true | ||
npm-build-script: | ||
description: 'npm build script to be called' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- uses: pnpm/action-setup@v3 | ||
name: Install pnpm | ||
id: pnpm-install | ||
with: | ||
version: 9 | ||
run_install: false | ||
|
||
- name: build docker image | ||
run: pnpm run $NPM_SCRIPT | ||
shell: bash | ||
env: | ||
NPM_SCRIPT: ${{ inputs.npm-build-script }} | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ inputs.docker-username }} | ||
password: ${{ inputs.docker-password }} | ||
|
||
- name: push docker image | ||
run: docker push $DOCKER_IMAGE --all-tags | ||
shell: bash | ||
env: | ||
DOCKER_IMAGE: ${{ inputs.docker-image }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: publish-docker-service-user-image | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
image: | ||
type: choice | ||
description: Docker image to be published | ||
options: | ||
- Game consumer | ||
- Game service | ||
- User service | ||
jobs: | ||
publish: | ||
env: | ||
DOCKER_IMAGE: > | ||
${{ fromJson('{ | ||
"Game consumer": "robertopintosl/one-game-backend-consumer-game", | ||
"Game service": "robertopintosl/one-game-backend-service-game", | ||
"User service": "robertopintosl/one-game-backend-service-user" | ||
}')[github.event.inputs.environment] }} | ||
NPM_BUILD_SCRIPT: > | ||
${{ fromJson('{ | ||
"Game consumer": "docker:build:game:consumer:npm", | ||
"Game service": "docker:build:game:service:npm", | ||
"User service": "docker:build:user:service:npm" | ||
}')[github.event.inputs.environment] }} | ||
name: Build and publish image | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: ./.github/actions/publish-docker-image | ||
with: | ||
docker-image: ${{ env.DOCKER_IMAGE }} | ||
docker-password: ${{ secrets.DOCKER_TOKEN }} | ||
docker-username: ${{ vars.DOCKER_USERNAME }} | ||
npm-build-script: ${{ env.NPM_BUILD_SCRIPT }} |