ci: correct Dockerfile based on mode #85
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: CI/CD Sapa Mitra Frontend | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
types: ["closed"] | |
branches: ["main"] | |
jobs: | |
build: | |
if: github.event_name == 'push' || github.event.pull_request.merged == true | |
name: Build Frontend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Insecure Docker Repository | |
run: | | |
sudo truncate -s-2 /etc/docker/daemon.json | |
echo ", \"insecure-registries\": [\"${{ secrets.DOCKER_REGISTRY_URL }}\"]}" | sudo tee -a /etc/docker/daemon.json | |
sudo systemctl restart docker | |
- name: Docker Auth | |
run: docker login ${{ secrets.DOCKER_REGISTRY_URL }} --username=${{ secrets.DOCKER_REGISTRY_USERNAME }} --password=${{ secrets.DOCKER_REGISTRY_PASSWORD }} | |
- name: Build and Push Docker Image | |
run: | | |
docker build --build-arg BUILD_HASH=$(git rev-parse --short HEAD) --no-cache -t sapa-mitra-frontend -f Dockerfile.production . | |
docker tag sapa-mitra-frontend ${{ secrets.DOCKER_REGISTRY_URL }}/${{ secrets.DOCKER_REGISTRY_USERNAME }}/sapa-mitra-frontend:latest | |
docker push ${{ secrets.DOCKER_REGISTRY_URL }}/${{ secrets.DOCKER_REGISTRY_USERNAME }}/sapa-mitra-frontend:latest |