Skip to content

Commit

Permalink
fix(ci/cd): Update Github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Jul 23, 2024
1 parent 0a161ad commit 5c9ac96
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
39 changes: 19 additions & 20 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,44 @@ env:
DEPLOYMENT: paysage-ui
DEPLOYMENT_NAMESPACE: paysage
DEPLOYMENT_URL: https://paysage.dataesr.ovh
MM_NOTIFICATION_CHANNEL: 'bots'
MM_NOTIFICATION_CHANNEL: bots

jobs:
publish-ghcr:
name: Publish docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 🏁 Checkout
uses: actions/checkout@v4

- name: Log into registry
run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
- name: 🏷️ Get tag
id: tag
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Build image
run: docker build -t ${{ github.repository }} --build-arg MODE=production .
- name: 🔑 Login ghcr.io
run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}

- name: Get Tag
id: version
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: 🐋 Build Docker image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker build -t $IMAGE_ID:${{ steps.tag.outputs.tag }} -t $IMAGE_ID:latest --build-arg MODE=production .
- name: Push image
- name: 📦 Push Docker image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag ${{ github.repository }} $IMAGE_ID:latest
docker tag ${{ github.repository }} $IMAGE_ID:${{ steps.version.outputs.tag }}
docker push $IMAGE_ID:latest
docker push $IMAGE_ID:${{ steps.version.outputs.tag }}
docker push -a $IMAGE_ID
deploy:
name: Update production deployment
runs-on: ubuntu-latest
needs: publish-ghcr
steps:
- name: Check Out Repo
- name: 🏁 Checkout
uses: actions/checkout@v4

- name: Deploy to Cluster
- name: ☁️ Deploy to Cluster
id: kubectl-deploy
uses: dataesr/[email protected]
env:
Expand All @@ -58,7 +59,7 @@ jobs:
release:
name: Release new version
runs-on: ubuntu-latest
needs: publish-ghcr
needs: deploy
steps:
- name: Check Out Repo
uses: actions/checkout@v4
Expand All @@ -84,9 +85,7 @@ jobs:
body: "${{ steps.changelog.outputs.changes }}"

notify:
needs:
- deploy
- release
needs: release
if: always()
runs-on: ubuntu-latest
steps:
Expand Down
29 changes: 16 additions & 13 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,34 @@ env:
DEPLOYMENT: paysage-ui
DEPLOYMENT_NAMESPACE: paysage
DEPLOYMENT_URL: https://paysage.staging.dataesr.ovh
MM_NOTIFICATION_CHANNEL: 'bots'
MM_NOTIFICATION_CHANNEL: bots

jobs:
publish-ghcr:
name: Publish docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 🏁 Checkout
uses: actions/checkout@v4

- name: Log into registry
run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
- name: 🏷️ Get tag
id: tag
run: echo "tag=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT

- name: Build image
run: docker build -t ${{ github.repository }} --build-arg MODE=staging .
- name: 🔑 Login ghcr.io
run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}

- name: Get Tag
id: version
run: echo "tag=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: 🐋 Build Docker image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker build -t ${{ github.repository }}:staging --build-arg MODE=staging .
- name: Push image
- name: 📦 Push Docker image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag ${{ github.repository }} $IMAGE_ID:${{ steps.version.outputs.tag }}
docker push $IMAGE_ID:${{ steps.version.outputs.tag }}
docker push $IMAGE_ID:staging
deploy:
name: Update staging deployment
Expand Down Expand Up @@ -63,4 +66,4 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
mattermost_webhook_url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
mattermost_channel: ${{ env.MM_NOTIFICATION_CHANNEL}}
deployment_url: ${{ env.DEPLOYMENT_URL }}
deployment_url: ${{ env.DEPLOYMENT_URL }}

0 comments on commit 5c9ac96

Please sign in to comment.