|
16 | 16 |
|
17 | 17 | # TODO: test vars in-line vs. global env |
18 | 18 | env: |
19 | | - docker_user: ${{ secrets.DOCKERHUB_USERNAME }} |
| 19 | + DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }} |
| 20 | + GHCR_USER: ${{ github.actor }} |
20 | 21 | app_name: ${{ vars.APP_NAME }} |
21 | 22 |
|
22 | 23 | jobs: |
| 24 | + ghcr: |
| 25 | + strategy: |
| 26 | + fail-fast: true |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v3 |
| 31 | + - name: Docker meta |
| 32 | + id: meta |
| 33 | + uses: docker/metadata-action@v4 |
| 34 | + with: |
| 35 | + images: | |
| 36 | + ${{ env.GHCR_USER }}/${{ env.app_name }} |
| 37 | + tags: | |
| 38 | + type=schedule |
| 39 | + type=ref,event=branch |
| 40 | + type=ref,event=pr |
| 41 | + type=semver,pattern={{version}} |
| 42 | + type=semver,pattern={{major}}.{{minor}} |
| 43 | + type=semver,pattern={{major}} |
| 44 | + type=sha |
| 45 | + - name: Login to GitHub Container Registry |
| 46 | + uses: docker/login-action@v1 |
| 47 | + with: |
| 48 | + registry: ghcr.io |
| 49 | + username: ${{ env.GHCR_USER }} |
| 50 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + - name: Build and push Docker image |
| 52 | + uses: docker/build-push-action@v4 |
| 53 | + with: |
| 54 | + context: . |
| 55 | + push: ${{ github.event_name != 'pull_request' }} |
| 56 | + tags: ${{ steps.meta.outputs.tags }} |
| 57 | + labels: ${{ steps.meta.outputs.labels }} |
| 58 | + |
23 | 59 | docker: |
24 | 60 | strategy: |
25 | 61 | fail-fast: true |
|
32 | 68 | uses: docker/metadata-action@v4 |
33 | 69 | with: |
34 | 70 | # list of Docker images to use as base name for tags |
35 | | - # TODO: see above ^^ |
36 | 71 | images: | |
37 | | - ${{ env.docker_user }}/${{ env.app_name }} |
| 72 | + ${{ env.DOCKER_USER }}/${{ env.app_name }} |
38 | 73 | # generate Docker tags based on the following events/attributes |
39 | 74 | tags: | |
40 | 75 | type=schedule |
|
0 commit comments