|
1 |
| -name: Docker |
| 1 | +name: Build Image |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
@@ -51,44 +51,34 @@ jobs:
|
51 | 51 | steps:
|
52 | 52 | - uses: actions/checkout@v2
|
53 | 53 |
|
54 |
| - - name: Build image |
55 |
| - run: docker build . --file Dockerfile --tag $IMAGE_NAME |
56 |
| - |
57 | 54 | - name: Log in to GitHub Container Registry
|
58 | 55 | uses: docker/login-action@v1
|
59 | 56 | with:
|
60 | 57 | registry: ghcr.io
|
61 | 58 | username: ${{ github.repository_owner }}
|
62 | 59 | password: ${{ secrets.GITHUB_TOKEN }}
|
63 | 60 |
|
64 |
| - - name: Build and push image to Container Registry |
65 |
| - uses: docker/build-push-action@v2 |
66 |
| - with: |
67 |
| - push: true |
68 |
| - tags: | |
69 |
| - ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ github.sha }} |
70 |
| - ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ github.ref }} |
71 |
| - #- name: Log into registry |
72 |
| - # run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin |
73 |
| - |
74 |
| - #- name: Push image |
75 |
| - # run: | |
76 |
| - # IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME |
77 |
| - |
| 61 | + - name: Create Tagged Image Name |
| 62 | + run: | |
| 63 | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME |
| 64 | + |
78 | 65 | # Change all uppercase to lowercase
|
79 |
| - # IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') |
80 |
| - |
| 66 | + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') |
| 67 | + |
81 | 68 | # Strip git ref prefix from version
|
82 |
| - # VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') |
83 |
| - |
| 69 | + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') |
| 70 | + |
84 | 71 | # Strip "v" prefix from tag name
|
85 |
| - # [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') |
86 |
| - |
| 72 | + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') |
| 73 | + |
87 | 74 | # Use Docker `latest` tag convention
|
88 |
| - # [ "$VERSION" == "master" ] && VERSION=latest |
| 75 | + [ "$VERSION" == "master" ] && VERSION=latest |
89 | 76 |
|
90 |
| - # echo IMAGE_ID=$IMAGE_ID |
91 |
| - # echo VERSION=$VERSION |
| 77 | + echo "TAGGED_IMAGE_NAME=$IMAGE_ID:$VERSION" >> $GITHUB_ENV |
92 | 78 |
|
93 |
| - # docker tag $IMAGE_NAME $IMAGE_ID:$VERSION |
94 |
| - # docker push $IMAGE_ID:$VERSION |
| 79 | + - name: Build and push image to Container Registry |
| 80 | + uses: docker/build-push-action@v2 |
| 81 | + with: |
| 82 | + push: true |
| 83 | + tags: | |
| 84 | + ${{ env.TAGGED_IMAGE_NAME }} |
0 commit comments