|
| 1 | +name: Docker Image CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "*v*", "main" ] |
| 6 | + tags: |
| 7 | + - '*v*' |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + pull_request: |
| 11 | + branches: [ "*v*", "main" ] |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + packages: write |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Log in to GitHub Container Registry |
| 25 | + uses: docker/login-action@v3 |
| 26 | + with: |
| 27 | + registry: ghcr.io |
| 28 | + username: ${{ github.actor }} |
| 29 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + |
| 31 | + - name: Docker meta |
| 32 | + id: meta |
| 33 | + uses: docker/metadata-action@v5 |
| 34 | + with: |
| 35 | + images: ghcr.io/ethscriptions-protocol/ethscriptions-node |
| 36 | + tags: | |
| 37 | + # Latest commit SHA |
| 38 | + type=sha,format=short |
| 39 | + |
| 40 | + # Branch names (v1.0.0, main, etc) |
| 41 | + type=ref,event=branch |
| 42 | + |
| 43 | + # Git tags (v1.0.0, etc) |
| 44 | + type=ref,event=tag |
| 45 | + |
| 46 | + # Semantic versioning for releases |
| 47 | + type=semver,pattern={{version}},event=tag |
| 48 | + type=semver,pattern={{major}}.{{minor}},event=tag |
| 49 | + type=semver,pattern={{major}},event=tag |
| 50 | + |
| 51 | + # Latest release tag |
| 52 | + type=raw,value=latest-release,enable=${{ github.event_name == 'release' }} |
| 53 | + |
| 54 | + # Latest on main branch |
| 55 | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} |
| 56 | +
|
| 57 | + - name: Build and push Docker image |
| 58 | + uses: docker/build-push-action@v5 |
| 59 | + with: |
| 60 | + context: . |
| 61 | + push: true |
| 62 | + tags: ${{ steps.meta.outputs.tags }} |
| 63 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments