Skip to content

Commit

Permalink
ci: extend build and test workflow to tag releases
Browse files Browse the repository at this point in the history
  • Loading branch information
ae9is committed Jun 9, 2024
1 parent e063f7e commit 2d2e5bd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,42 @@ jobs:

- name: Test
run: make test-ci

- name: Test is release
if: startsWith(github.event.head_commit.message, 'release:') && github.event_name == 'push'
id: isRelease
run: |
echo "value=true" >> $GITHUB_OUTPUT
- name: Get release version string
if: steps.isRelease.outputs.value
id: getVersion
env:
MESSAGE: ${{ github.event.head_commit.message }}
run: |
VALUE=$(echo "${MESSAGE}" | sed 's/release://' | sed 's/[[:space:]]*//g')
echo "value=${VALUE}" >> $GITHUB_OUTPUT
- name: Create tag
if: steps.isRelease.outputs.value
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.getVersion.outputs.value }}",
sha: context.sha
})
- name: Tag build
if: steps.isRelease.outputs.value
env:
RELEASE_TAG: ${{ steps.getVersion.outputs.value }}
run: make docker-tag-github

- name: Push build to container registry
if: steps.isRelease.outputs.value
env:
RELEASE_TAG: ${{ steps.getVersion.outputs.value }}
run: make docker-push-github
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,17 @@ docker-bash-model-api:
docker run -it --entrypoint /bin/bash ${MODEL_API_IMAGE_ID}

docker-tag:
docker tag ${GRAPHQL_API_IMAGE_ID} ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${NAME}/graphql-api:latest
docker tag ${MODEL_API_IMAGE_ID} ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${NAME}/model-api:latest
docker tag ${GRAPHQL_API_IMAGE_ID} ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${NAME}/graphql-api:${RELEASE_TAG}
docker tag ${MODEL_API_IMAGE_ID} ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${NAME}/model-api:${RELEASE_TAG}

docker-tag-github:
docker tag ${GRAPHQL_API_IMAGE_ID} ghcr.io/ae9is/${NAME}-graphql-api:${RELEASE_TAG}
docker tag ${MODEL_API_IMAGE_ID} ghcr.io/ae9is/${NAME}-model-api:${RELEASE_TAG}

docker-push:
docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${NAME}/graphql-api:latest
docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${NAME}/model-api:latest
docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${NAME}/graphql-api:${RELEASE_TAG}
docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${NAME}/model-api:${RELEASE_TAG}

docker-push-github:
docker push ghcr.io/ae9is/${NAME}-graphql-api:${RELEASE_TAG}
docker push ghcr.io/ae9is/${NAME}-model-api:${RELEASE_TAG}

0 comments on commit 2d2e5bd

Please sign in to comment.