.github/workflows/release.yml #33
Workflow file for this run
This file contains hidden or 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
| on: | |
| release: | |
| types: | |
| - published | |
| - unpublished | |
| - created | |
| - edited | |
| - deleted | |
| - prereleased | |
| - released | |
| # Trigger the action manually from the UI | |
| # workflow_dispatch: | |
| # inputs: | |
| # branch: | |
| # description: 'Branch' | |
| # required: true | |
| # default: 'develop' | |
| # type: choice | |
| # options: | |
| # - develop | |
| # - staging | |
| # - master | |
| # tag: | |
| # description: 'Version Tag' | |
| # required: true | |
| # default: 'warning' | |
| jobs: | |
| build: | |
| name: Build Docker Images | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: DockerHub login | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5.5.1 | |
| with: | |
| images: "unicef/hope-country-workspace" | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=ref,event=tag | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{raw}} | |
| env: | |
| DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | |
| - run: | | |
| echo "Log level: $TAG" | |
| echo "Environment: $ENVIRONMENT" | |
| echo "${{ toJSON(github.event) }}" | |
| env: | |
| LEVEL: ${{ inputs.tag }} | |
| ENVIRONMENT: ${{ inputs.environment }} | |
| - if: github.event_name == 'release' && github.event.action == 'created' | |
| run: echo "version=${{ steps.meta.outputs.version }}dev" >> "$GITHUB_OUTPUT" | |
| - if: github.event_name == 'release' && github.event.action == 'prereleased' | |
| run: echo "version=${{ steps.meta.outputs.version }}rc" >> "$GITHUB_OUTPUT" | |
| - if: github.event_name == 'release' && github.event.action == 'published' | |
| run: echo "version=${{ steps.meta.outputs.version }}" >> "$GITHUB_OUTPUT" | |
| - if: github.event_name == 'release' && github.event.action == 'published' | |
| run: | | |
| echo "Build ... unicef/hope-country-workspace:${{ steps.meta.outputs.version }}-${{ env.version }}" | |
| docker build \ | |
| --target dist \ | |
| -t "unicef/hope-country-workspace:${{ steps.meta.outputs.version }}" \ | |
| --cache-from "type=gha" \ | |
| --cache-to "type=gha,mode=max" \ | |
| -f docker/Dockerfile . | |
| docker push "unicef/hope-country-workspace:${{ steps.meta.outputs.version }}" | |
| docker inspect --format='{{index .Id}}' "unicef/hope-country-workspace:${{ steps.meta.outputs.version }}" | |
| # - name: Generate artifact attestation | |
| # uses: actions/attest-build-provenance@v1 | |
| # with: | |
| # subject-name: unicef/hope-country-workspace | |
| # subject-digest: ${{ steps.push.outputs.digest }} | |
| # push-to-registry: true |