Github action connect to deployment repo: push issue #11
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: Continious Integration flow | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.x" | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./code/docker/4-kapend/myfirst | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/kapend:${{ github.sha }} | |
- name: Checkout Kubernetes manifests repo | |
uses: actions/checkout@v2 | |
with: | |
repository: 'stark275/k8sDeployConfig-argocd' # Remplacez par le nom de votre dépôt | |
token: ${{ secrets.GH_PAT }} # Un Personal Access Token (PAT) avec les droits appropriés | |
- name: Update Kubernetes Manifest | |
run: | | |
# Mettez à jour vos fichiers de manifeste ici. Par exemple : | |
sed -i 's|image: stark275/kapend:.*|image: stark275/kapend:${{ github.sha }}|' ./k8s/03-kapend.yaml | |
- name: Commit and push | |
run: | | |
git config --global user.name 'stark' | |
git config --global user.email 'stark@example.com' | |
git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/stark275/k8sDeployConfig-argocd.git | |
git commit -am 'Update image tag to ${{ github.sha }}' | |
git push origin main |