Skip to content

Commit 10527a4

Browse files
Added test for non default Dockerfile (#13)
* Added test for non default dockerfile Co-authored-by: goruha <[email protected]> Co-authored-by: Cloud Posse Bot (CI/CD) <[email protected]> Co-authored-by: goruha <[email protected]>
1 parent ce09a36 commit 10527a4

File tree

5 files changed

+52
-2
lines changed

5 files changed

+52
-2
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test docker build custom file
2+
on:
3+
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered
4+
# #
5+
# # Added pull_request to register workflow from the PR.
6+
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo
7+
# pull_request: {}
8+
workflow_dispatch: {}
9+
10+
jobs:
11+
setup:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Setup
15+
run: echo "Do setup"
16+
17+
test:
18+
runs-on: ubuntu-latest
19+
needs: [setup]
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
24+
- uses: ./
25+
id: current
26+
with:
27+
workdir: ./test/custom
28+
file: Dockerfile_complex
29+
organization: ${{ github.event.repository.owner.login }}
30+
repository: ${{ github.event.repository.name }}
31+
registry: registry.hub.docker.com
32+
login: ${{ secrets.DOCKERHUB_USERNAME }}
33+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
34+
35+
- uses: nick-fields/assert-action@v1
36+
with:
37+
expected: 'registry.hub.docker.com/cloudposse/github-action-docker-build-push'
38+
actual: ${{ steps.current.outputs.image }}
39+
40+
teardown:
41+
runs-on: ubuntu-latest
42+
needs: [test]
43+
if: ${{ always() }}
44+
steps:
45+
- name: Tear down
46+
run: echo "Do Tear down"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Build Docker image and push it.
106106
107107
| Name | Description | Default | Required |
108108
|------|-------------|---------|----------|
109+
| file | Dockerfile name | Dockerfile | false |
109110
| login | Docker login | | false |
110111
| organization | Organization | N/A | true |
111112
| password | Docker password | | false |

action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ inputs:
1111
default: './'
1212
file:
1313
description: 'Dockerfile name'
14-
required: false
14+
required: false
15+
default: 'Dockerfile'
1516
organization:
1617
description: 'Organization'
1718
required: true
@@ -68,7 +69,7 @@ runs:
6869
uses: docker/build-push-action@v2
6970
with:
7071
context: ${{ inputs.workdir }}
71-
file: ${{ inputs.file }}
72+
file: ${{ inputs.workdir }}/${{ inputs.file }}
7273
pull: true
7374
push: true
7475
cache-from: type=gha

docs/github-action.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
| Name | Description | Default | Required |
55
|------|-------------|---------|----------|
6+
| file | Dockerfile name | Dockerfile | false |
67
| login | Docker login | | false |
78
| organization | Organization | N/A | true |
89
| password | Docker password | | false |

test/custom/Dockerfile_complex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM nginx:1.23.0-alpine

0 commit comments

Comments
 (0)