Skip to content
Snippets Groups Projects
Commit 52381650 authored by Victoire DE LACHARRIERE's avatar Victoire DE LACHARRIERE :man_fairy_medium_light_skin_tone:
Browse files

update tp github actions mandatory part

parent a9d7c541
No related branches found
No related tags found
No related merge requests found
Pipeline #94448 passed
......@@ -35,7 +35,7 @@ Historically many companies were using <a href="https://jenkins.io/" target="_bl
### First steps into the CI World
!!! note
Use the repository you just forked
Use the repository your repository from the end of the Docker TP
Most of the CI services use a <a href="https://yaml.org/" target="_blank">yaml</a> file (except Jenkins that uses a… <a href="https://groovy-lang.org/" target="_blank">Groovy</a> file…) to describe the expected steps to be done over the pipeline execution. Go on and create your first main.yml file into your project’s root directory.
......@@ -119,12 +119,12 @@ on:
jobs:
test-backend:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
#checkout your github code using actions/checkout@v2.5.0
- uses: actions/checkout@v2.5.0
#checkout your github code using actions/checkout@v4
- uses: actions/checkout@v4
#do the same with another action (actions/setup-java@v3) that enable to setup jdk 21
#do the same with another action (actions/setup-java@v4) that enable to setup jdk 21
- name: Set up JDK 21
#TODO
......@@ -174,18 +174,18 @@ Maybe the template Build a docker image can help you! For now, we only need to b
build-and-push-docker-image:
needs: test-backend
# run only when code is compiling and tests are passing
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
# steps to perform in job
steps:
- name: Checkout code
uses: actions/checkout@v2.5.0
uses: actions/checkout@v4
- name: Build image and push backend
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
# relative path to the place where source code with Dockerfile is located
context: ./simple-api
context:
# Note: tags has to be all lower-case
tags: ${{secrets.DOCKERHUB_USERNAME}}/tp-devops-simple-api:latest
......@@ -207,17 +207,17 @@ Don’t forget to do a docker login and to put your credentials on secrets!
```yaml
- name: Login to DockerHub
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
```
And after modify job `Build image and push backend` to add a `push` action:
```yaml
- name: Build image and push backend
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
# relative path to the place where source code with Dockerfile is located
context: ./simple-api
context:
# Note: tags has to be all lower-case
tags: ${{secrets.DOCKERHUB_USERNAME}}/tp-devops-simple-api:latest
# build on feature branches, push only on main branch
......@@ -260,7 +260,7 @@ Create your free-tier account on <a href="https://sonarcloud.io/" target="_blank
Set up your pipeline to use **SonarCloud** analysis while testing.
For that, you need to modify your first step named **Build and test** with Maven and change sonar organization and project key.
For that, you need to add a **new step** after **Build and test** with Maven and change sonar organization and project key.
```shell
mvn -B verify sonar:sonar -Dsonar.projectKey=<your-project-key> -Dsonar.organization=<your-organization> -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} --file ./simple-api/pom.xml
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment