Merge pull request #133 from fastcampus-711/develop #76
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: Next.js Docker Build 🍃 | |
# triggers ci cd when you push code to any branch | |
on: | |
push: | |
branches: [ "main" ] | |
workflow_dispatch: | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
environment: dev | |
env: | |
image_name: ${{ secrets.DOCKER_REPO }}/docker/711-front | |
image_tag: ${{ github.sha }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Building Docker Image | |
run: | | |
docker login ${{ secrets.DOCKER_REPO }} -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ env.image_name }}:${{ env.image_tag }} -t ${{ env.image_name }}:latest . | |
docker push ${{ env.image_name }}:${{ env.image_tag }} | |
docker push ${{ env.image_name }}:latest | |
deployment: | |
name: Argo Deployment | |
runs-on: ubuntu-22.04 | |
environment: dev | |
env: | |
branch_name: helm | |
image_tag: ${{ github.sha }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.branch_name }} | |
submodules: 'recursive' # Actions -> General -> Workflow permissions (add write) | |
token: ${{ secrets.GITHUB_TOKEN }} # Ensure the token is being used | |
- name: Change values.yaml | |
run: | | |
sed -i "s/tag: \".*\"/tag: \"${{ env.image_tag }}\"/g" values.yaml | |
- name: Git Push | |
run: | | |
git config --global user.email "GitHub Actions [email protected]" | |
git config --global user.name "GitHub Actions Bot" | |
git add values.yaml | |
git commit -m "change image tag: ${{ env.image_tag }}" | |
git -c http.extraHeader="AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}" pull --rebase origin ${{ env.branch_name }} | |
git -c http.extraHeader="AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}" push origin ${{ env.branch_name }} |