update to net 8 #116
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: GDSC API Build | |
on: | |
push: | |
branches: [ main, dev ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
BRANCH: ${{ steps.extract_branch.outputs.branch }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Packages Docker Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Extract branch name | |
shell: bash | |
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: Build and push to GitHub Packages | |
uses: docker/build-push-action@v3 | |
env: | |
BRANCH: ${{ steps.extract_branch.outputs.branch }} | |
with: | |
context: . | |
secrets: GIT_AUTH_TOKEN=${{ secrets.CR_PAT }} | |
push: true | |
tags: ghcr.io/gdsc-upt/gdsc-backend-${{ env.BRANCH }}:latest | |
deploy: | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Pull & run image on server | |
uses: appleboy/ssh-action@master | |
env: | |
BRANCH: ${{ needs.build.outputs.BRANCH }} | |
with: | |
host: gdscupt.tech | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
script: /home/docker/deploy/deploy.sh /home/docker/gdsc/backend-${{ env.BRANCH }} |