|
| 1 | +--- |
| 2 | +name: Create and publish a Docker image |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + pull_request: |
| 9 | + schedule: |
| 10 | + - cron: '45 18 * * 3' |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: ghcr.io |
| 14 | + IMAGE_NAME: ${{ github.repository }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + docker: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + - name: Set up Docker Buildx |
| 26 | + uses: docker/setup-buildx-action@v3 |
| 27 | + - name: Build and export Docker image |
| 28 | + uses: docker/build-push-action@v5 |
| 29 | + with: |
| 30 | + context: . |
| 31 | + tags: ros-infrastructure/prerelease_website:test |
| 32 | + cache-from: type=gha |
| 33 | + cache-to: type=gha,mode=max |
| 34 | + - name: Log in to the Container registry |
| 35 | + if: contains(fromJSON('["push", "schedule"]'), github.event_name) |
| 36 | + uses: docker/login-action@v3 |
| 37 | + with: |
| 38 | + registry: ${{ env.REGISTRY }} |
| 39 | + username: ${{ github.actor }} |
| 40 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + - name: Extract metadata (tags, labels) for Docker |
| 42 | + if: contains(fromJSON('["push", "schedule"]'), github.event_name) |
| 43 | + id: meta |
| 44 | + uses: docker/metadata-action@v5 |
| 45 | + with: |
| 46 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 47 | + tags: | |
| 48 | + type=ref,event=branch |
| 49 | + type=schedule,${{ github.ref_name }} |
| 50 | + - name: Build and push Docker image |
| 51 | + if: contains(fromJSON('["push", "schedule"]'), github.event_name) |
| 52 | + uses: docker/build-push-action@v5 |
| 53 | + with: |
| 54 | + context: . |
| 55 | + push: true |
| 56 | + tags: ${{ steps.meta.outputs.tags }} |
| 57 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments