diff --git a/.github/workflows/full-pipeline.yaml b/.github/workflows/full-pipeline.yaml index 2b343c2..b98c46e 100644 --- a/.github/workflows/full-pipeline.yaml +++ b/.github/workflows/full-pipeline.yaml @@ -1,7 +1,7 @@ name: Main workflow on: [push, workflow_dispatch] env: # Set the secret as an input - docker_username: ${{ github.actor }} + docker_username: ${{ github.actor }} docker_password: ${{ secrets.GITHUB_TOKEN }} #Nees to be set to be made available to the workflow APP_NAME: ${{ github.event.repository.name }} BUILD_NUMBER: ${{ github.run_number }} @@ -12,21 +12,21 @@ env: # Set the secret as an input IMAGE: ${{ github.repository_owner }}/${{ github.event.repository.name }} BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} COMMIT_URL: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} - + jobs: Build: runs-on: ubuntu-latest container: gradle:6-jdk11 steps: - name: Clone down repository - uses: actions/checkout@v4 + uses: actions/checkout@v4 - name: Build application run: bash ci/build-app.sh - name: Test run: bash ci/unit-test-app.sh - name: Upload repo uses: actions/upload-artifact@v4 - with: + with: name: code path: . include-hidden-files: true @@ -40,12 +40,12 @@ jobs: name: code path: . - name: run linting - uses: super-linter/super-linter/slim@v7 + uses: super-linter/super-linter/slim@v7 env: DEFAULT_BRANCH: main # To report GitHub Actions status checks - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DISABLE_ERRORS: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DISABLE_ERRORS: true Docker-image: runs-on: ubuntu-latest needs: [Build] @@ -79,6 +79,12 @@ jobs: with: name: code path: . + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: @@ -109,7 +115,7 @@ jobs: name: code path: . - name: Execute performance test - run: bash ci/performance-test.sh + run: bash ci/performance-test.sh Deploy: runs-on: ubuntu-latest needs: [Docker-image, Security-scan, Component-test, Performance-test] @@ -117,8 +123,14 @@ jobs: - name: Download code uses: actions/download-artifact@v4 with: - name: code + name: code path: . + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Deploy to production run: bash ci/start-application.sh - name: stop production environment diff --git a/ci/component-test.sh b/ci/component-test.sh index 3479f20..a910f32 100644 --- a/ci/component-test.sh +++ b/ci/component-test.sh @@ -1,3 +1,4 @@ #! /bin/bash [[ -z "${docker_username}" ]] && DockerRepo='' || DockerRepo="${docker_username}/" +echo "$docker_password" | docker login ghcr.io --username "$docker_username" --password-stdin docker_username=$DockerRepo docker compose -f component-test/docker-compose.yml --project-directory . -p ci up --build --exit-code-from test \ No newline at end of file diff --git a/ci/performance-test.sh b/ci/performance-test.sh index 312a270..2e55231 100644 --- a/ci/performance-test.sh +++ b/ci/performance-test.sh @@ -1,3 +1,4 @@ #! /bin/bash [[ -z "${docker_username}" ]] && DockerRepo='' || DockerRepo="${docker_username}/" +echo "$docker_password" | docker login ghcr.io --username "$docker_username" --password-stdin docker_username=$DockerRepo docker compose -f performance-test/docker-compose.yml --project-directory . -p ci up --build --exit-code-from test \ No newline at end of file diff --git a/lab-01-get-ready.md b/lab-01-get-ready.md index 106b79f..256c99c 100644 --- a/lab-01-get-ready.md +++ b/lab-01-get-ready.md @@ -3,7 +3,7 @@ ## Learning Goals - Create a Kosli account -- Fork and set up the sample application repository +- Set up this repository on your GitHub account - Verify that the CI/CD pipeline runs successfully - Understand the basic structure of the application and its deployment process @@ -40,7 +40,7 @@ In this lab, you will: #### Create a Kosli account -- Navigate to [kosli.com/sign-up]) +- Navigate to [kosli.com/sign-up]() - Choose to sign up with GitHub - Complete the registration process - Verify your email address if required @@ -52,7 +52,10 @@ So far so good :tada:. We will go a lot more in detail with Kosli in the next se - Navigate to the labs repositorys main page (the repository you're currently viewing) - Click the "Use this template" button in the top-right corner of the page -- Select your personal GitHub account as the destination +- Select "Create a new repository" +- Select your personal GitHub account as the "Owner" and name the repository `labs` +- Optionally, add a description and choose to make the repository public or private +- Click "Create repository from template" - Wait for GitHub to complete the copy process - You should now have a copy at `https://github.com/YOUR-GITHUB-USERNAME/labs` @@ -108,7 +111,7 @@ So far so good :tada:. We will go a lot more in detail with Kosli in the next se #### View the Docker image 1. Go to your GitHub profile page -2. Click on "Packages" tab +2. Click on "Packages" in the left sidebar 3. You should see the `labs` package 4. Click on it to view details about the Docker image 5. Note the image tag (usually `latest`) and the SHA digest @@ -120,7 +123,7 @@ So far so good :tada:. We will go a lot more in detail with Kosli in the next se Before moving to the next lab, ensure you have: - ✅ A Kosli account at app.kosli.com with an organization created -- ✅ A forked copy of the labs repository under your GitHub account +- ✅ A copy of the labs repository under your GitHub account - ✅ GitHub Actions successfully completed all jobs in the workflow - ✅ A Docker image published to your GitHub Container Registry - ✅ Understanding of the basic pipeline structure