Update dependency next from v14.2.18 to v15.0.3 #10884
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: Publish Docker image | |
on: | |
push: | |
branches: [main, develop] | |
paths-ignore: | |
- "apps/skde/**" | |
pull_request: | |
branches: [main, develop, dependency_updates] | |
paths-ignore: | |
- "apps/skde/**" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
push_to_registries: | |
name: Push Docker image to docker hub | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: "eu-west-1" | |
steps: | |
- name: Set release variables | |
if: github.ref == 'refs/heads/main' | |
run: | | |
echo "S3Key='prod-mong-api.json'" >> $GITHUB_ENV | |
echo "env_name=prod-mong-api" >> $GITHUB_ENV | |
echo "version_label=${GITHUB_SHA:0:7}_prod_${RANDOM}" >> $GITHUB_ENV | |
echo "descr='Release tag deploy'" >> $GITHUB_ENV | |
echo "cloudfront_id=${{ secrets.CLOUDFRONT_ID_PROD }}" >> $GITHUB_ENV | |
- name: Set QA variables | |
if: github.ref == 'refs/heads/develop' | |
run: | | |
echo "S3Key='qa-mong-api.json'" >> $GITHUB_ENV | |
echo "env_name=qa-mong-api" >> $GITHUB_ENV | |
echo "version_label=${GITHUB_SHA:0:7}_qa_${RANDOM}" >> $GITHUB_ENV | |
echo "descr='Main commits deploy'" >> $GITHUB_ENV | |
echo "cloudfront_id=${{ secrets.CLOUDFRONT_ID_QA }}" >> $GITHUB_ENV | |
- name: Check out the repo | |
uses: actions/[email protected] | |
- run: corepack enable && yarn install | |
- run: yarn workspace api run build | |
- name: Lint Dockerfile | |
uses: hadolint/[email protected] | |
with: | |
dockerfile: "apps/api/Dockerfile" | |
- name: Prepare | |
id: docker_meta | |
uses: docker/[email protected] | |
with: | |
images: hnskde/mong-api | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Test docker image | |
run: | | |
docker build -t test --file apps/api/Dockerfile . | |
docker run -e ORIGIN="skde.no" -d test | |
sleep 5 # wait for it to die, if not working | |
docker kill $(docker ps --filter ancestor=test -q) | |
- name: Build and push to Docker Hub | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: ./apps/api/Dockerfile | |
build-args: version=${{ env.version_label }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Update elasticbeanstalk | |
if: github.event_name != 'pull_request' | |
run: | | |
aws elasticbeanstalk create-application-version --application-name mong-api --source-bundle S3Bucket="elasticbeanstalk-eu-west-1-247247832514",S3Key=${{ env.S3Key }} --version-label ${{ env.version_label }} --description ${{ env.descr }} | |
aws elasticbeanstalk update-environment --environment-name ${{ env.env_name }} --version-label ${{ env.version_label }} | |
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then | |
aws elasticbeanstalk update-environment --environment-name verify-mong-api --version-label ${{ env.version_label }} | |
fi | |
- name: Create CloudFront invalidation | |
if: github.event_name != 'pull_request' | |
run: | | |
aws cloudfront create-invalidation \ | |
--distribution-id ${{ env.cloudfront_id }}\ | |
--paths "/*" |