From 59a14b31e1573cb05735c263a0d9d412eb0c1882 Mon Sep 17 00:00:00 2001 From: Jessica Stratton Date: Wed, 4 Oct 2023 12:07:24 -0700 Subject: [PATCH] added landing page workflow --- .github/workflows/cd-dfa-landing-page.yml | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/cd-dfa-landing-page.yml diff --git a/.github/workflows/cd-dfa-landing-page.yml b/.github/workflows/cd-dfa-landing-page.yml new file mode 100644 index 000000000..6c9db94db --- /dev/null +++ b/.github/workflows/cd-dfa-landing-page.yml @@ -0,0 +1,75 @@ +#CD pipeline for dfa landing page +name: cd-dfa-landing-page + +on: + push: + branches: + #- master + - feature/dfa_cleanup + + paths: + - "landing-page/**" + - ".github/workflows/cd-dfa-landing-page.yml" + +env: + IMAGE_NAME: dfa-landing-page + WORKING_DIRECTORY: ./landing-page/src + +jobs: + build: + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@v3 + + - uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + + - name: Log into registry + uses: docker/login-action@v2 + with: + registry: ${{ secrets.DOCKER_PROJECT_REGISTRY }} + username: ${{ secrets.DOCKER_PROJECT_USERNAME }} + password: ${{ secrets.DOCKER_PROJECT_PASSWORD_BUILDER }} + + - name: Set image repository + id: set_image_repository + run: | + # Set image repository and change all uppercase to lowercase + DOCKER_REPOSITORY=$(echo ${{ secrets.DOCKER_PROJECT_REGISTRY }}/${{ env.IMAGE_NAME }} | tr '[A-Z]' '[a-z]') + echo "::set-output name=docker-repository::$DOCKER_REPOSITORY" + + - name: Pull image + env: + DOCKER_REPOSITORY: ${{ steps.set_image_repository.outputs.docker-repository }} + run: docker pull $DOCKER_REPOSITORY:latest || true + + - name: Bump version and push tag + id: tag_version + uses: mathieudutour/github-tag-action@v6.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + tag_prefix: ${{ env.IMAGE_NAME }}=v + fetch_all_tags: true + + - name: Build image + env: + DOCKER_REPOSITORY: ${{ steps.set_image_repository.outputs.docker-repository }} + working-directory: ${{ env.WORKING_DIRECTORY }} + run: | + VERSION=$(echo "${{ steps.tag_version.outputs.new_tag }}" | awk -F=v '{print $NF}') + + echo DOCKER_REPOSITORY=${{ env.DOCKER_REPOSITORY }} + echo VERSION=$VERSION + + tar -czh . | docker build --load --tag ${{ env.DOCKER_REPOSITORY }}:latest --cache-from=${{ env.DOCKER_REPOSITORY }}:latest --build-arg VERSION=$VERSION - + docker tag ${{ env.DOCKER_REPOSITORY }}:latest ${{ env.DOCKER_REPOSITORY }}:$VERSION + + - name: Push image + env: + DOCKER_REPOSITORY: ${{ steps.set_image_repository.outputs.docker-repository }} + run: | + docker push --all-tags ${{ env.DOCKER_REPOSITORY }} \ No newline at end of file