chore(deps): update github-actions #316
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: Docker Image CI | |
on: | |
pull_request: | |
branches: | |
- master | |
- staging | |
types: | |
- opened | |
- reopened | |
- synchronize | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
docker-ci-setup: | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
timeout-minutes: 5 | |
outputs: | |
ENVIRONMENT: ${{ steps.output.outputs.ENVIRONMENT }} | |
steps: | |
- name: set target branch | |
id: target | |
run: | | |
echo "TARGET_REF=refs/heads/${{ github.base_ref }}" >> "$GITHUB_ENV" | |
- name: staging | |
if: ${{ env.TARGET_REF == 'refs/heads/staging' }} | |
run: | | |
echo "ENVIRONMENT=staging" >> "$GITHUB_ENV" | |
- name: production | |
if: ${{ env.TARGET_REF == 'refs/heads/master' }} | |
run: | | |
echo "ENVIRONMENT=production" >> "$GITHUB_ENV" | |
- name: Error | |
if: ${{ env.TARGET_REF != 'refs/heads/master' && env.TARGET_REF != 'refs/heads/staging' }} | |
run: | | |
echo "[ERROR] Invalid target branch: ${{ env.TARGET_REF }}. Skipping deployment." | |
exit 1 | |
- name: Output environment | |
id: output | |
run: | | |
echo "ENVIRONMENT=${{ env.ENVIRONMENT }}" >> "$GITHUB_OUTPUT" | |
docker-ci: | |
needs: docker-ci-setup | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 | |
- name: Create image tag | |
id: tag | |
run: | | |
SHA=${{github.sha}} | |
TAG="${{vars.IMAGE}}:$(TZ=UTC-9 date +'%Y%m')-${SHA:0:7}" | |
echo "TAG_FOR_PULL=${TAG}" >> "$GITHUB_OUTPUT" | |
if [ "${{ needs.docker-ci-setup.outputs.ENVIRONMENT }}" = "production" ]; then | |
LATEST="${{vars.IMAGE}}:latest" | |
echo "TAGS=${TAG},${LATEST}" >> "$GITHUB_OUTPUT" | |
else | |
echo "TAGS=${TAG}" >> "$GITHUB_OUTPUT" | |
fi | |
echo "Generated image tag: ${TAG}" | |
- name: Build | |
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: false | |
tags: ${{ steps.tag.outputs.TAGS }} | |
cache-from: type=gha | |
cache-to: type=gha, mode=max |