Explorar el Código

Container image creation workflow

Andy Esnard hace 1 año
padre
commit
ad185a20ee
Se han modificado 1 ficheros con 35 adiciones y 0 borrados
  1. 35 0
      .github/workflows/docker-image.yml

+ 35 - 0
.github/workflows/docker-image.yml

@@ -0,0 +1,35 @@
+name: Build Docker Image
+
+on:
+  push:
+    branches:
+      - AniList  # Déclenche l'action seulement pour la branche "main"
+  pull_request:
+    branches:
+      - AniList
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+
+    steps:
+      # Vérifie le code dans le dépôt
+      - name: Checkout code
+        uses: actions/checkout@v2
+
+      # Configure Docker pour s'authentifier sur DockerHub
+      - name: Log in to DockerHub
+        run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
+
+      # Build l'image Docker avec trois tags: un pour le SHA du commit, un pour latest, et un pour Anilist
+      - name: Build the Docker image
+        run: |
+          docker build . -t ${{ secrets.DOCKER_USERNAME }}/MyAnimeBot:${{ github.sha }} -t ${{ secrets.DOCKER_USERNAME }}/MyAnimeBot:anilist -t ${{ secrets.DOCKER_USERNAME }}/MyAnimeBot:latest
+
+      # Pousse l'image Docker sur DockerHub
+      - name: Push the Docker image
+        run: docker push ${{ secrets.DOCKER_USERNAME }}/MyAnimeBot:${{ github.sha }}
+      - name: Push the Docker image with latest tag
+        run: docker push ${{ secrets.DOCKER_USERNAME }}/MyAnimeBot:anilist
+      - name: Push the Docker image with latest tag
+        run: docker push ${{ secrets.DOCKER_USERNAME }}/MyAnimeBot:latest