|
| 1 | +# Workflow Requirements: |
| 2 | +# |
| 3 | +# 1. In repository Settings -> Actions -> General, ensure "Allow all actions and reusable workflows" is selected, and that under "Workflow permissions", "Read repository contents and packages permissions" is checked. |
| 4 | +# 2. On https://hub.docker.com click your username in the top right, then Account Settings, then select "Security" from the left nav menu; generate a new Access Token for this repo with read & write perms. |
| 5 | +# 3. In repository Settings -> Secrets and variables -> Actions, create a new Repository secret; call it ``DOCKERHUB_TOKEN`` and paste the Docker Hub access token you just created as the value. |
| 6 | +# |
| 7 | +name: Release on Tag |
| 8 | +on: |
| 9 | + push: |
| 10 | + tags: |
| 11 | + - '*' |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + packages: write |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + - name: Set up Docker Buildx |
| 21 | + uses: docker/setup-buildx-action@v2 |
| 22 | + - name: Login to GHCR |
| 23 | + run: echo "${{secrets.GITHUB_TOKEN}}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin |
| 24 | + - name: Login to Docker Hub |
| 25 | + uses: docker/login-action@v2 |
| 26 | + with: |
| 27 | + username: jantman |
| 28 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 29 | + - name: Docker Build and Push |
| 30 | + uses: docker/build-push-action@v4 |
| 31 | + with: |
| 32 | + push: true |
| 33 | + sbom: true |
| 34 | + labels: | |
| 35 | + org.opencontainers.image.url=https://github.com/${{ github.repository }} |
| 36 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 37 | + org.opencontainers.image.version=${{ github.ref_name }} |
| 38 | + org.opencontainers.image.revision=${{ github.sha }} |
| 39 | + tags: | |
| 40 | + ghcr.io/${{ github.repository }}:${{ github.ref_name }} |
| 41 | + ghcr.io/${{ github.repository }}:latest |
| 42 | + ${{ github.repository }}:${{ github.ref_name }} |
| 43 | + ${{ github.repository }}:latest |
| 44 | + - name: Create Release |
| 45 | + id: create_release |
| 46 | + uses: actions/create-release@v1 |
| 47 | + env: |
| 48 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token |
| 49 | + with: |
| 50 | + tag_name: ${{ github.ref }} |
| 51 | + release_name: Release ${{ github.ref }} |
| 52 | + body: | |
| 53 | + Release ${{ github.ref_name }}. |
| 54 | +
|
| 55 | + **GitHub Package:** https://github.com/users/jantman/packages/container/package/machine-access-control |
| 56 | +
|
| 57 | + **Docker Images:** |
| 58 | + ghcr.io/${{ github.repository }}:${{ github.ref_name }} |
| 59 | + ghcr.io/${{ github.repository }}:latest |
| 60 | + ${{ github.repository }}:${{ github.ref_name }} |
| 61 | + ${{ github.repository }}:latest |
| 62 | + draft: false |
| 63 | + prerelease: false |
0 commit comments