Skip to content

Commit

Permalink
remove snapshot option and reserve latest tag for release (#28236)
Browse files Browse the repository at this point in the history
  • Loading branch information
spbolton authored Apr 15, 2024
1 parent 1cce60d commit 2aaf68e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 38 deletions.
36 changes: 22 additions & 14 deletions .github/actions/deploy-artifact-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,41 @@ The action accepts the following inputs:
- `docker_platforms`: Docker platforms to build the image on. Default is 'linux/amd64'.
- `docker_registry`: Docker registry to push the image to (DOCKER.IO, GHCR.IO, BOTH). Default is 'DOCKER.IO'.
- `build_run_id`: The run id of the build to pull the artifact from. This is required.
- `docker_context` : The docker context from the docker directory to use for the build. This is required if build-run-id is not used.
- `commit_id`: The commit id that triggered the build. This is required.
- `variant`: The branch or type of build to tag the image with. This is required.
- `image_name`: The name of the image to build. e.g 'dotcms/dotcms'
- `ref`: The the branch or tag that triggered the build e.g. the docker environment name "trunk", "nightly" if "release" then the name will not be used in the tag.
- `docker_tag`: The docker tag to use for the image. This is required.
- `latest` : If true, the image will be tagged as latest, usually reserved for the agile release e.g. dotcms/dotcms:latest
- `do_deploy`: Actually do the final deploy, set to false for testing. Default is 'true'.
- `docker_io_username`: Docker.io username.
- `docker_io_token`: Docker.io token.
- `ghcr_io_username`: GHCR.io username.
- `ghcr_io_token`: GHCR.io token.
- `github_token`: GitHub token. This is required.
- `build_args`: Build arguments to pass to the docker build command. Default is ''.

## Usage

Here is an example of how to use this action in a workflow:

```yaml
- name: Deploy Docker Artifact
uses: ./.github/actions/deploy-artifact-docker
with:
docker_platforms: linux/amd64,linux/arm64
build_run_id: ${{ github.event.workflow_run.id }}
commit_id: ${{ github.event.workflow_run.head_sha }}
variant: dotcms/dotcms:master
docker_tag: dotcms/dotcms:master_latest_SNAPSHOT
do_deploy: false
docker_io_username: ${{ secrets.DOCKER_USERNAME }}
docker_io_token: ${{ secrets.DOCKER_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
```
- name: Build/Push Docker Dev Image
id: docker_build_dev
if: inputs.deploy-dev-image
uses: ./.github/actions/deploy-artifact-docker
with:
image_name: dotcms/dotcms-dev
docker_platforms: linux/amd64,linux/arm64
docker_context: dev-env
commit_id: ${{ github.sha }}
ref: trunk
do_deploy: ${{ vars.DOCKER_DEPLOY || 'true' }} # default to true, set to disable in fork
docker_io_username: ${{ secrets.DOCKER_USERNAME }}
docker_io_token: ${{ secrets.DOCKER_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# Make value below which is source dotcms/dotcms tag to base dev image on dynamic to use whatever tag created above
build_args: |
DOTCMS_DOCKER_TAG=trunk
This action is part of a larger workflow and is designed to work in conjunction with other actions. It is used to build and push a Docker image as part of a continuous integration/continuous deployment (CI/CD) pipeline.
15 changes: 1 addition & 14 deletions .github/actions/deploy-artifact-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ inputs:
ref:
description: 'The branch or type of build to tag the image with'
required: true
snapshot:
description: 'tag the image as a snapshot'
default: 'false'
latest:
description: 'Tag the image as latest'
description: 'If true, the image will be tagged as latest, usually reserved for the agile release e.g. dotcms/dotcms:latest'
default: 'false'
do_deploy:
description: 'Actually do the final deploy, set to false for testing'
Expand Down Expand Up @@ -89,7 +86,6 @@ runs:
shell: bash
id: set-common-vars
env:
SNAPSHOT: ${{ inputs.snapshot }}
LATEST: ${{ inputs.latest }}
REF: ${{ inputs.ref }}
run: |
Expand All @@ -99,18 +95,9 @@ runs:
tag_prefix="${REF}_"
fi
# Now use environment variables instead of GitHub Actions expressions
if [ "$SNAPSHOT" = "true" ] && [ "$LATEST" = "true" ]; then
latest_snapshot="true"
else
latest_snapshot="false"
fi
echo "FULL_TAGS_OUTPUT<<EOF" >> $GITHUB_ENV
echo "type=raw,value=${tag_prefix}{{sha}},enable=true" >> $GITHUB_ENV
echo "type=raw,value=${tag_prefix}latest,enable=$LATEST" >> $GITHUB_ENV
echo "type=raw,value=${tag_prefix}SNAPSHOT,enable=$SNAPSHOT" >> $GITHUB_ENV
echo "type=raw,value=${tag_prefix}latest_SNAPSHOT,enable=${latest_snapshot}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Docker.io login
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build-test-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ jobs:
with:
artifact-run-id: ${{ needs.initialize.outputs.artifact-run-id }}
environment: trunk
snapshot: true
latest: true
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build-test-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ jobs:
with:
artifact-run-id: ${{ needs.initialize.outputs.artifact-run-id }}
environment: nightly
snapshot: true
latest: true
deploy-dev-image: true
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/reusable-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
artifact-run-id:
default: ${{ github.run_id }}
type: string
snapshot:
default: false
type: boolean
latest:
default: false
type: boolean
Expand Down Expand Up @@ -53,7 +50,6 @@ jobs:
build_run_id: ${{ inputs.artifact-run-id }}
commit_id: ${{ github.sha }}
ref: ${{ inputs.environment }}
snapshot: ${{ inputs.snapshot }}
latest: ${{ inputs.latest }}
do_deploy: ${{ vars.DOCKER_DEPLOY || 'true' }} # default to true, set to disable in fork
docker_io_username: ${{ secrets.DOCKER_USERNAME }}
Expand All @@ -69,15 +65,14 @@ jobs:
docker_context: dev-env
commit_id: ${{ github.sha }}
ref: ${{ inputs.environment }}
snapshot: ${{ inputs.snapshot }}
latest: ${{ inputs.latest }}
do_deploy: ${{ vars.DOCKER_DEPLOY || 'true' }} # default to true, set to disable in fork
docker_io_username: ${{ secrets.DOCKER_USERNAME }}
docker_io_token: ${{ secrets.DOCKER_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# Make value below which is source dotcms/dotcms tag to base dev image on dynamic to use whatever tag created above
build_args: |
DOTCMS_DOCKER_TAG=${{ inputs.environment }}_latest_SNAPSHOT
DOTCMS_DOCKER_TAG=${{ inputs.environment }}
# The CLI artifacts are built and uploaded to Artifactory using the 'deploy-artifact-cli' action.
- name: CLI Deploy
Expand Down

0 comments on commit 2aaf68e

Please sign in to comment.