From 55307888dddbda84a3e9b717b2e59f87177cd5fe Mon Sep 17 00:00:00 2001 From: Ivica Matic Date: Thu, 4 Apr 2024 10:20:05 +0100 Subject: [PATCH] feat: added github action on release --- .../build-docker-images-on-release.yml | 41 ++++++++++++++ .github/workflows/docker-build-prod.yml | 53 ------------------- .github/workflows/docker-build-staging.yml | 53 ------------------- 3 files changed, 41 insertions(+), 106 deletions(-) create mode 100644 .github/workflows/build-docker-images-on-release.yml delete mode 100644 .github/workflows/docker-build-prod.yml delete mode 100644 .github/workflows/docker-build-staging.yml diff --git a/.github/workflows/build-docker-images-on-release.yml b/.github/workflows/build-docker-images-on-release.yml new file mode 100644 index 0000000..fb8e882 --- /dev/null +++ b/.github/workflows/build-docker-images-on-release.yml @@ -0,0 +1,41 @@ +name: Build docker images on release + +on: + release: + types: [created] + +jobs: + build-and-push-docker-image: + runs-on: ubuntu-latest + steps: + # Checkout the main repository + - name: Checkout main repo + uses: actions/checkout@v3 + + # Checkout the inner repository (nested git repo) + - name: Checkout stac-proprietary-parsers repo + uses: actions/checkout@v3 + with: + repository: SpatialDays/stac-proprietary-parsers + token: ${{ secrets.GH_PAT }} + path: app/stac/services/metadata_parsers/proprietary + + # Log in to the Container registry + - uses: docker/login-action@v2 + name: Log in to the Container registry + with: + registry: ${{ secrets.EO_PROJ_DOCKER_LOGIN_SERVER}} + username: ${{ secrets.EO_PROJ_DOCKER_USERNAME }} + password: ${{ secrets.EO_PROJ_DOCKER_PASSWORD }} + - uses: docker/setup-buildx-action@v2 + name: Set up Docker Buildx + id: buildx + - uses: docker/build-push-action@v4 + name: Build and push Docker image + with: + context: . + file: Dockerfile + cache-from: type=registry,ref=${{ secrets.EO_PROJ_DOCKER_LOGIN_SERVER }}/${{ github.event.repository.name }}:cache + cache-to: type=registry,ref=${{ secrets.EO_PROJ_DOCKER_LOGIN_SERVER }}/${{ github.event.repository.name }}:cache,mode=max + push: true + tags: ${{ secrets.EO_PROJ_DOCKER_LOGIN_SERVER }}/${{ github.event.repository.name }}:${{ github.event.release.tag_name }} diff --git a/.github/workflows/docker-build-prod.yml b/.github/workflows/docker-build-prod.yml deleted file mode 100644 index 2ed2cd4..0000000 --- a/.github/workflows/docker-build-prod.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Build and push Docker image for production environment - -permissions: - contents: read - -on: - push: - branches: - - prod - -jobs: - docker-build-push-dev: - runs-on: ubuntu-latest - steps: - # Checkout the main repository - - name: Checkout main repo - uses: actions/checkout@v3 - - # Checkout the inner repository (nested git repo) - - name: Checkout stac-proprietary-parsers repo - uses: actions/checkout@v3 - with: - repository: SpatialDays/stac-proprietary-parsers - token: ${{ secrets.GH_PAT }} - path: app/stac/services/metadata_parsers/proprietary - - # Set Short SHA - - name: Set Short SHA - run: echo "SHORT_SHA=$(git rev-parse --short=7 $GITHUB_SHA)" >> $GITHUB_ENV - - # Log in to the Container registry - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ secrets.EO_PROJ_PROD_DOCKER_REGISTRY_URL }} - username: ${{ secrets.EO_PROJ_PROD_DOCKER_USERNAME }} - password: ${{ secrets.EO_PROJ_PROD_DOCKER_PASSWORD }} - - # Set up Docker Buildx - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - # Build and push Docker image under tag ${{ env.SHORT_SHA }} - - name: Build and push Docker image under tag ${{ env.SHORT_SHA }} - uses: docker/build-push-action@v4 - with: - context: . - file: Dockerfile - cache-from: type=registry,ref=${{ secrets.EO_PROJ_PROD_DOCKER_REGISTRY_URL }}/stac-generator:cache - cache-to: type=registry,ref=${{ secrets.EO_PROJ_PROD_DOCKER_REGISTRY_URL }}/stac-generator:cache,mode=max - push: true - tags: ${{ secrets.EO_PROJ_PROD_DOCKER_REGISTRY_URL }}/stac-generator:${{ env.SHORT_SHA }} diff --git a/.github/workflows/docker-build-staging.yml b/.github/workflows/docker-build-staging.yml deleted file mode 100644 index 5d149a4..0000000 --- a/.github/workflows/docker-build-staging.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Build and push Docker image for staging/development environment - -permissions: - contents: read - -on: - push: - branches: - - staging - -jobs: - docker-build-push-dev: - runs-on: ubuntu-latest - steps: - # Checkout the main repository - - name: Checkout main repo - uses: actions/checkout@v3 - - # Checkout the inner repository (nested git repo) - - name: Checkout stac-proprietary-parsers repo - uses: actions/checkout@v3 - with: - repository: SpatialDays/stac-proprietary-parsers - token: ${{ secrets.GH_PAT }} - path: app/stac/services/metadata_parsers/proprietary - - # Set Short SHA - - name: Set Short SHA - run: echo "SHORT_SHA=$(git rev-parse --short=7 $GITHUB_SHA)" >> $GITHUB_ENV - - # Log in to the Container registry - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ secrets.EO_PROJ_STAGING_DOCKER_REGISTRY_URL }} - username: ${{ secrets.EO_PROJ_STAGING_DOCKER_USERNAME }} - password: ${{ secrets.EO_PROJ_STAGING_DOCKER_PASSWORD }} - - # Set up Docker Buildx - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - # Build and push Docker image under tag ${{ env.SHORT_SHA }} - - name: Build and push Docker image under tag ${{ env.SHORT_SHA }} - uses: docker/build-push-action@v4 - with: - context: . - file: Dockerfile - cache-from: type=registry,ref=${{ secrets.EO_PROJ_STAGING_DOCKER_REGISTRY_URL }}/stac-generator:cache - cache-to: type=registry,ref=${{ secrets.EO_PROJ_STAGING_DOCKER_REGISTRY_URL }}/stac-generator:cache,mode=max - push: true - tags: ${{ secrets.EO_PROJ_STAGING_DOCKER_REGISTRY_URL }}/stac-generator:${{ env.SHORT_SHA }} \ No newline at end of file