Test #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pipeline Raspberry | |
on: # Triggers the workflow | |
pull_request: # This workflow will run only for pull requests | |
branches: # This workflow will run only for the main branch | |
- main | |
permissions: | |
pull-requests: write | |
env: | |
# Use docker.io for Docker Hub if empty | |
SHA: ${{ github.event.pull_request.head.sha || github.event.after }} | |
REACT_APP_URL_API: ${{ secrets.REACT_APP_URL_API }} | |
jobs: | |
##### Check de l'image Front ###### | |
################################### | |
check-front-image: | |
runs-on: ubuntu-latest # OS | |
steps: | |
- name: Checkout # Checkout the repository | |
uses: actions/checkout@v3 # Checkout the repository | |
- name: Login to Docker Hub # Login to Docker Hub | |
uses: docker/login-action@v2 # Docker login action | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} # Docker Hub username | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} # Docker Hub access token | |
- name: Extract Docker Front metadata # Extract Docker Front metadata | |
id: meta # Step ID | |
uses: docker/[email protected] # Docker metadata action | |
with: | |
images: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }} # Docker Front image | |
labels: | | |
org.opencontainers.image.revision=${{ env.SHA }} | |
tags: | | |
type=edge,branch=$repo.default_branch | |
type=semver,pattern=v{{version}} | |
type=sha,prefix=,suffix=,format=short | |
- name: Check Front image # Check Front image | |
uses: docker/[email protected] # Docker scout action | |
with: | |
command: cves # Command to run on the image | |
image: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_FRONT }}:${{ vars.DOCKER_FRONT_VERSION }} # Docker Front image version to check | |
exit-code: true # Exit code | |
##### Check de l'image Back ###### | |
################################### | |
check-back-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Extract Docker Back metadata | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }} | |
labels: | | |
org.opencontainers.image.revision=${{ env.SHA }} | |
tags: | | |
type=edge,branch=$repo.default_branch | |
type=semver,pattern=v{{version}} | |
type=sha,prefix=,suffix=,format=short | |
- name: Check Back image | |
uses: docker/[email protected] | |
with: | |
command: cves | |
image: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_BACK }}:${{ vars.DOCKER_BACK_VERSION }} | |
exit-code: true | |
##### Deploiement docker compose ###### | |
################################ | |
deploy: | |
needs: [check-front-image, check-back-image] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Copy docker-compose.yml to Raspberry Pi | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.RASPBERRY_PI_HOST }} | |
username: ${{ secrets.RASPBERRY_PI_USERNAME }} | |
key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} | |
passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} | |
source: "./docker-compose.yml" | |
target: "./Documents/" | |
- name: Deploy to Raspberry Pi | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.RASPBERRY_PI_HOST }} | |
username: ${{ secrets.RASPBERRY_PI_USERNAME }} | |
key: ${{ secrets.RASPBERRY_PI_SSH_KEY }} | |
passphrase: ${{ secrets.RASPBERRY_PI_SSH_PASSPHRASE }} | |
script: | | |
cd Documents | |
sudo docker compose up -d | |