diff --git a/.github/workflows/build-develop-image.yaml b/.github/workflows/build-main-webapp-image.yaml similarity index 97% rename from .github/workflows/build-develop-image.yaml rename to .github/workflows/build-main-webapp-image.yaml index 31449ad0..d308b619 100644 --- a/.github/workflows/build-develop-image.yaml +++ b/.github/workflows/build-main-webapp-image.yaml @@ -1,4 +1,4 @@ -name: Build and push image from develop +name: Build and push image from main on: pull_request: types: [ closed ] diff --git a/.github/workflows/build-staging-webapp-image.yaml b/.github/workflows/build-staging-webapp-image.yaml new file mode 100644 index 00000000..646a1daf --- /dev/null +++ b/.github/workflows/build-staging-webapp-image.yaml @@ -0,0 +1,65 @@ +name: Build and push image from develop +on: + push: + branches: + - feat/add-develop-to-claasp-webapp +# pull_request: +# types: [ closed ] +# branches: +# - develop + +jobs: + build-image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + + - name: Login dockerhub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_REGISTRY_USER }} + password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} + + - name: Build & Push + uses: docker/build-push-action@v4 + id: built-image + with: + context: . + file: ./docker/Dockerfile + push: true + tags: tiicrc/claasp-lib-staging:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: Get current commit information + run: | + git clone ${{ secrets.DEPLOYMENT_REPOSITORY }} deployment-staging-repo + git config --global user.name 'Github' + git config --global user.email ${{ secrets.DEPLOYMENT_REPOSITORY_EMAIL }} + cd deployment-staging-repo + git checkout develop + echo "Date: $(date) Commit: $(git rev-parse HEAD)" >> claasp-dev.log + git add claasp-dev.log + git commit -m "Updating deployment-staging-repo from github" + git push origin develop