├── .github └── workflows │ ├── app1.yaml │ ├── app2.yaml │ └── app3.yaml ├── README.md ├── app1 ├── container │ ├── .DS_Store │ ├── Dockerfile │ └── index.html └── readme.md ├── app2 ├── container │ ├── .DS_Store │ ├── Dockerfile │ └── index.html └── readme.md └── app3 ├── container ├── .DS_Store ├── Dockerfile └── index.html └── readme.md /.github/workflows/app1.yaml: -------------------------------------------------------------------------------- 1 | name: 'Container CI' 2 | 3 | on: 4 | 5 | push: 6 | branches: 7 | - main 8 | paths: 9 | - app1/** 10 | 11 | pull_request: # [master, next] 12 | paths: 13 | - app1/** 14 | 15 | jobs: 16 | 17 | container: 18 | name: 'Container' 19 | runs-on: ubuntu-latest 20 | 21 | # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest 22 | defaults: 23 | run: 24 | working-directory: app1 25 | shell: bash 26 | 27 | steps: 28 | 29 | - if: github.event_name == 'pull_request' 30 | name: Generate build number 31 | id: buildnumber 32 | uses: einaregilsson/build-number@v3 33 | with: 34 | token: ${{secrets.github_token}} 35 | 36 | - name: Check Out Repo 37 | if: github.event_name == 'pull_request' 38 | uses: actions/checkout@v2 39 | 40 | - name: Login to Docker Hub 41 | if: github.event_name == 'pull_request' 42 | uses: docker/login-action@v1 43 | with: 44 | username: ${{ secrets.DOCKERHUB_USERNAME }} 45 | password: ${{ secrets.DOCKERHUB_TOKEN }} 46 | 47 | - name: Set up Docker Buildx 48 | if: github.event_name == 'pull_request' 49 | id: buildx 50 | uses: docker/setup-buildx-action@v1 51 | 52 | - name: Build and push 53 | if: github.event_name == 'pull_request' 54 | id: docker_build 55 | uses: docker/build-push-action@v2 56 | with: 57 | context: ./app1/container 58 | file: ./app1/container/Dockerfile 59 | push: true 60 | tags: ${{ secrets.DOCKERHUB_USERNAME }}/app1:${{ steps.buildnumber.outputs.build_number }} 61 | -------------------------------------------------------------------------------- /.github/workflows/app2.yaml: -------------------------------------------------------------------------------- 1 | name: 'Container CI' 2 | 3 | on: 4 | 5 | push: 6 | branches: 7 | - main 8 | paths: 9 | - app2/** 10 | 11 | pull_request: # [master, next] 12 | paths: 13 | - app2/** 14 | 15 | 16 | jobs: 17 | 18 | 19 | # FAZER SOMENTE NO PULL ESSE DO DOCKER 20 | 21 | 22 | container: 23 | name: 'Container' 24 | runs-on: ubuntu-latest 25 | 26 | # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest 27 | defaults: 28 | run: 29 | working-directory: app2 30 | shell: bash 31 | 32 | steps: 33 | 34 | - if: github.event_name == 'pull_request' 35 | name: Generate build number 36 | id: buildnumber 37 | uses: einaregilsson/build-number@v3 38 | with: 39 | token: ${{secrets.github_token}} 40 | 41 | - name: Check Out Repo 42 | if: github.event_name == 'pull_request' 43 | uses: actions/checkout@v2 44 | 45 | - name: Login to Docker Hub 46 | if: github.event_name == 'pull_request' 47 | uses: docker/login-action@v1 48 | with: 49 | username: ${{ secrets.DOCKERHUB_USERNAME }} 50 | password: ${{ secrets.DOCKERHUB_TOKEN }} 51 | 52 | - name: Set up Docker Buildx 53 | if: github.event_name == 'pull_request' 54 | id: buildx 55 | uses: docker/setup-buildx-action@v1 56 | 57 | - name: Build and push 58 | if: github.event_name == 'pull_request' 59 | id: docker_build 60 | uses: docker/build-push-action@v2 61 | with: 62 | context: ./app2/container 63 | file: ./app2/container/Dockerfile 64 | push: true 65 | tags: ${{ secrets.DOCKERHUB_USERNAME }}/app2:${{ steps.buildnumber.outputs.build_number }} 66 | -------------------------------------------------------------------------------- /.github/workflows/app3.yaml: -------------------------------------------------------------------------------- 1 | name: 'Container CI' 2 | 3 | on: 4 | 5 | push: 6 | branches: 7 | - main 8 | paths: 9 | - app3/** 10 | 11 | pull_request: # [master, next] 12 | paths: 13 | - app3/** 14 | 15 | 16 | jobs: 17 | 18 | 19 | # FAZER SOMENTE NO PULL ESSE DO DOCKER 20 | 21 | 22 | container: 23 | name: 'Container' 24 | runs-on: ubuntu-latest 25 | 26 | # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest 27 | defaults: 28 | run: 29 | working-directory: app3 30 | shell: bash 31 | 32 | steps: 33 | 34 | - if: github.event_name == 'pull_request' 35 | name: Generate build number 36 | id: buildnumber 37 | uses: einaregilsson/build-number@v3 38 | with: 39 | token: ${{secrets.github_token}} 40 | 41 | - name: Check Out Repo 42 | if: github.event_name == 'pull_request' 43 | uses: actions/checkout@v2 44 | 45 | - name: Login to Docker Hub 46 | if: github.event_name == 'pull_request' 47 | uses: docker/login-action@v1 48 | with: 49 | username: ${{ secrets.DOCKERHUB_USERNAME }} 50 | password: ${{ secrets.DOCKERHUB_TOKEN }} 51 | 52 | - name: Set up Docker Buildx 53 | if: github.event_name == 'pull_request' 54 | id: buildx 55 | uses: docker/setup-buildx-action@v1 56 | 57 | - name: Build and push 58 | if: github.event_name == 'pull_request' 59 | id: docker_build 60 | uses: docker/build-push-action@v2 61 | with: 62 | context: ./app3/container 63 | file: ./app3/container/Dockerfile 64 | push: true 65 | tags: ${{ secrets.DOCKERHUB_USERNAME }}/app3:${{ steps.buildnumber.outputs.build_number }} 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Github Actions 2 | 3 | ## Container 4 | 5 | Repositório usado como exemplo no pipeline do Github Actions para buildar containers. 6 | 7 | 8 | https://github.com/jonathanbaraldi/github-actions-container/ 9 | 10 | 11 | # UDEMY 12 | 13 | Link para o curso na Udemy: 14 | 15 | https://www.udemy.com/course/devops-mao-na-massa-docker-kubernetes-rancher/?referralCode=E0F907D36B02CEE83227 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app1/container/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonathanbaraldi/github-actions-container/d65f9656dd6c5efcd22ac3a855e2d629054fc940/app1/container/.DS_Store -------------------------------------------------------------------------------- /app1/container/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | COPY . /usr/share/nginx/html/ 3 | COPY . /var/www/html/ -------------------------------------------------------------------------------- /app1/container/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

DevOps Ninja

13 |

app111111

14 | 15 | 16 | -------------------------------------------------------------------------------- /app1/readme.md: -------------------------------------------------------------------------------- 1 | Arquivo contendo as informações para realização dos builds da app1 2 | 3 | -------------------------------------------------------------------------------- /app2/container/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonathanbaraldi/github-actions-container/d65f9656dd6c5efcd22ac3a855e2d629054fc940/app2/container/.DS_Store -------------------------------------------------------------------------------- /app2/container/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | COPY . /usr/share/nginx/html/ 3 | COPY . /var/www/html/ -------------------------------------------------------------------------------- /app2/container/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

DevOps Ninja

13 |

app2222

14 | 15 | 16 | -------------------------------------------------------------------------------- /app2/readme.md: -------------------------------------------------------------------------------- 1 | Arquivo contendo as informações para realização dos builds da app2 2 | 3 | 4 | -------------------------------------------------------------------------------- /app3/container/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonathanbaraldi/github-actions-container/d65f9656dd6c5efcd22ac3a855e2d629054fc940/app3/container/.DS_Store -------------------------------------------------------------------------------- /app3/container/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | COPY . /usr/share/nginx/html/ 3 | COPY . /var/www/html/ -------------------------------------------------------------------------------- /app3/container/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

DevOps Ninja

13 |

app3333

14 | 15 | 16 | -------------------------------------------------------------------------------- /app3/readme.md: -------------------------------------------------------------------------------- 1 | Arquivo contendo as informações para realização dos builds da app3 2 | 3 | 4 | --------------------------------------------------------------------------------