|
1 | | -name: release |
| 1 | +name: Build and Release |
2 | 2 | on: |
3 | 3 | push: |
4 | 4 | tags: |
5 | 5 | - "v*.*.*" |
6 | 6 | env: |
7 | | - BUILD_IMAGE: bedasoftware/fhir-sdc |
8 | | - CACHE_IMAGE: bedasoftware/fhir-sdc:latest |
| 7 | + REGISTRY: ghcr.io |
| 8 | + IMAGE_NAME: ${{ github.repository }} |
9 | 9 | jobs: |
10 | | - Release: |
| 10 | + build-and-push-images: |
11 | 11 | runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + packages: write |
12 | 15 | steps: |
13 | | - - name: Login to Docker Hub |
14 | | - uses: docker/login-action@v1 |
15 | | - with: |
16 | | - username: ${{ secrets.DOCKER_HUB_USERNAME }} |
17 | | - password: ${{ secrets.DOCKER_HUB_TOKEN }} |
18 | | - - uses: actions/checkout@v2 |
19 | | - - run: docker pull ${{ env.CACHE_IMAGE }} || true |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v4 |
20 | 18 | - name: Extract branch name |
21 | 19 | shell: bash |
22 | 20 | run: echo "branch=$(echo ${GITHUB_REF#refs/tags/v})" >>$GITHUB_OUTPUT |
23 | 21 | id: extract_branch |
24 | | - - name: Set up Docker Buildx |
25 | | - id: buildx |
26 | | - uses: docker/setup-buildx-action@v1 |
27 | | - - run: docker run --rm --privileged tonistiigi/binfmt --install all |
28 | | - - run: >- |
29 | | - docker buildx build --platform linux/arm64,linux/amd64 |
30 | | - --cache-from ${{ env.CACHE_IMAGE }} --push |
31 | | - --tag ${{ env.BUILD_IMAGE }}:${{ steps.extract_branch.outputs.branch }} --tag ${{ env.CACHE_IMAGE }} . |
| 22 | + - name: Log in to the Container registry |
| 23 | + uses: docker/login-action@v3 |
| 24 | + with: |
| 25 | + registry: ${{ env.REGISTRY }} |
| 26 | + username: ${{ github.actor }} |
| 27 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + - name: Extract metadata (tags, labels) for Docker |
| 29 | + id: meta |
| 30 | + uses: docker/metadata-action@v5 |
| 31 | + with: |
| 32 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 33 | + - name: Build and push Docker image (With commit hash) |
| 34 | + uses: docker/build-push-action@6 |
| 35 | + with: |
| 36 | + context: . |
| 37 | + push: true |
| 38 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.extract_branch.outputs.branch }} |
| 39 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments