Prod-backend-Express #9
This file contains hidden or 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: Deploy Backend Express to Prod | |
run-name: Prod-backend-Express | |
on: | |
# run it on push to the staging repository branch | |
push: | |
branches: | |
- master | |
paths: | |
- 'backend-express/**' | |
env: | |
CONTEXT: backend-express | |
ENV: prod | |
jobs: | |
deploy-backend-postgres: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Variables | |
id: vars | |
run: | | |
echo "VERSION=1.0.${{ github.run_number }}" >> "$GITHUB_ENV" | |
echo "IMAGE=ghcr.io/digitalproductschool/${{ github.event.repository.name }}/${{ env.CONTEXT }}" >> "$GITHUB_ENV" | |
- name: Setup pack | |
id: setup-pack | |
uses: buildpacks/github-actions/setup-pack@v5.1.0 | |
- name: Login to Github Packages | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{ secrets.GHCR_PAT }} | |
- name: Build image and push to GitHub Container Registry | |
id: package | |
run: | | |
#!/usr/bin/env bash | |
pack build --path ${DIR} --builder paketobuildpacks/builder:base --publish ${REPO}:${TAG} | |
shell: bash | |
env: | |
REPO: ${{ env.IMAGE }} | |
TAG: ${{ env.VERSION }} | |
DIR: ./${{ env.CONTEXT }} | |
- name: Update Helm | |
run: | | |
chmod +x deployment/scripts/update-image-value.sh | |
./deployment/scripts/update-image-value.sh ${{ env.VERSION }} ${{ env.IMAGE }} ${{ env.ENV }} ${{ env.CONTEXT }} ${{ github.event.repository.name }} | |
- name: Commit changes | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add . | |
git commit -m "Deploy ${{ env.CONTEXT }} to ${{ env.ENV }} 🤖" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GH_ACTIONS_BOT_ACCESS_TOKEN}} | |
branch: ${{ github.ref }} |