-
Notifications
You must be signed in to change notification settings - Fork 624
47 lines (36 loc) · 1.95 KB
/
docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This is a GitHub Actions yaml file.
# This file will build and push the Docker image to Docker Hub when a commit is pushed to the master branch.
# The name of the workflow. This is the name that will be displayed on the Actions tab.
name: Deploy Docker Image
# The event that triggers the workflow.
# The workflow_dispatch event allows you to trigger a workflow run manually from the GitHub Actions tab.
on: workflow_dispatch
# A workflow run is made up of one or more jobs that can run sequentially or in parallel.
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on.
# The GitHub-hosted runner is a virtual machine hosted by GitHub that runs the Linux operating system.
# The ubuntu-latest workflow will use the latest version of Ubuntu available on GitHub-hosted runners.
runs-on: ubuntu-latest
# The 'if' conditional statement allows you to skip a job or step unless a condition is met.
# The following conditional statement will skip the job if the current branch is not master.
if: github.ref == 'refs/heads/master'
# The steps that the job will execute.
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it.
- uses: actions/checkout@v3
# Runs a single command using the runners shell.
# This step will login to Docker Hub using the DOCKER_USER and DOCKER_PASSWORD secrets.
- name: docker login
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
# This step will build the Docker image using the Dockerfile in the root directory.
- name: Build the Docker image
run: docker build . --file Dockerfile --tag rhinosecuritylabs/cloudgoat:latest
# This step will push the Docker image to Docker Hub.
- name: Docker Push
run: docker push rhinosecuritylabs/cloudgoat:latest