Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,32 @@ jobs:
just test

- name: Set Docker image tag to the shortened commit sha for updates of the main branch
id: image-tag-main
if: github.ref == 'refs/heads/main'
run: |
echo IMAGE_TAG=$(git rev-parse --short=10 "$GITHUB_SHA") >> "$GITHUB_ENV"
echo IMAGE_TAG=$(git rev-parse --short=10 "$GITHUB_SHA") >> "$GITHUB_OUTPUT"
- name: Set Docker image tag to the git tag for tagged builds
id: image-tag-release
if: startsWith(github.ref, 'refs/tags/')
run: |
echo IMAGE_TAG="$GITHUB_REF_NAME" >> "$GITHUB_ENV"
echo IMAGE_TAG="$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
- name: Set Docker image target name
if: env.IMAGE_TAG != ''
id: target-image
if: steps.image-tag-main.outputs.IMAGE_TAG || steps.image-tag-release.outputs.IMAGE_TAG
env:
IMAGE_TAG: ${{ steps.image-tag-main.outputs.IMAGE_TAG || steps.image-tag-release.outputs.IMAGE_TAG }}
run: |
echo TARGET_IMAGE=us-docker.pkg.dev/${{ secrets.DOCKER_IMAGE_PATH }}:${IMAGE_TAG} >> "$GITHUB_ENV"
echo TARGET_IMAGE=us-docker.pkg.dev/${{ secrets.DOCKER_IMAGE_PATH }}:"${IMAGE_TAG}" >> "$GITHUB_OUTPUT"
- name: Tag Docker image
if: env.TARGET_IMAGE != ''
if: steps.target-image.outputs.TARGET_IMAGE
env:
TARGET_IMAGE: ${{ steps.target-image.outputs.TARGET_IMAGE }}
run: |
docker tag local/socorro_app:latest "$TARGET_IMAGE"
- name: Push the Docker image to GAR
if: env.TARGET_IMAGE != ''
if: steps.target-image.outputs.TARGET_IMAGE
uses: mozilla-it/deploy-actions/docker-push@4784cb70739a4f32ce010921f60fb1ebbc791a38 # v6.2.2
with:
image_tags: ${{ env.TARGET_IMAGE }}
image_tags: ${{ steps.target-image.outputs.TARGET_IMAGE }}
workload_identity_pool_project_number: ${{ secrets.WORKLOAD_IDENTITY_POOL_PROJECT_NUMBER }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
# Determine tag
base_tag="$(date +v%Y.%m.%d)"
tag="$base_tag"
gh api "repos/${{ github.repository }}/tags" --paginate \
gh api "repos/$GITHUB_REPOSITORY/tags" --paginate \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

-q '.[].name | select(startswith("'"$tag"'"))' > matching_tags
for i in 1 2 3 4 5 6 7 8 9 error; do
if ! grep -qx "$tag" matching_tags; then
Expand All @@ -29,6 +29,6 @@ jobs:
done

# Create release
gh release create --repo "${{ github.repository }}" --draft --generate-notes "$tag"
gh release create --repo "$GITHUB_REPOSITORY" --draft --generate-notes "$tag"
env:
GH_TOKEN: ${{ github.token }}