|
| 1 | +name: publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['main'] |
| 6 | + tags: |
| 7 | + - 'v*.*.*' |
| 8 | + |
| 9 | +concurrency: ${{ github.ref }} |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-and-push-image: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + packages: write |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - name: qemu |
| 20 | + uses: docker/setup-qemu-action@v3 |
| 21 | + - uses: docker/setup-buildx-action@v3 |
| 22 | + - name: Login to Docker Hub |
| 23 | + uses: docker/login-action@v3 |
| 24 | + with: |
| 25 | + username: blinklabs |
| 26 | + password: ${{ secrets.DOCKER_PASSWORD }} # uses token |
| 27 | + - name: Login to GHCR |
| 28 | + uses: docker/login-action@v3 |
| 29 | + with: |
| 30 | + registry: ghcr.io |
| 31 | + username: ${{ github.actor }} |
| 32 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + - id: meta |
| 34 | + uses: docker/metadata-action@v5 |
| 35 | + with: |
| 36 | + images: | |
| 37 | + blinklabs/openvpn |
| 38 | + ghcr.io/blinklabs-io/openvpn |
| 39 | + tags: | |
| 40 | + # version |
| 41 | + type=match,pattern=v(.*),group=1 |
| 42 | + # branch |
| 43 | + type=ref,event=branch |
| 44 | + - name: push |
| 45 | + uses: docker/build-push-action@v6 |
| 46 | + with: |
| 47 | + context: . |
| 48 | + push: true |
| 49 | + platforms: linux/amd64,linux/arm64 |
| 50 | + tags: ${{ steps.meta.outputs.tags }} |
| 51 | + labels: ${{ steps.meta.outputs.labels }} |
| 52 | + # Update Docker Hub from README |
| 53 | + - name: Docker Hub Description |
| 54 | + uses: peter-evans/dockerhub-description@v4 |
| 55 | + with: |
| 56 | + username: blinklabs |
| 57 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 58 | + repository: blinklabs/openvpn |
| 59 | + readme-filepath: ./README.md |
| 60 | + short-description: "Simple OpenVPN image" |
| 61 | + |
| 62 | + github-release: |
| 63 | + runs-on: ubuntu-latest |
| 64 | + permissions: |
| 65 | + contents: write |
| 66 | + needs: [build-and-push-image] |
| 67 | + steps: |
| 68 | + - run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV" |
| 69 | + - uses: actions/github-script@v7 |
| 70 | + if: startsWith(github.ref, 'refs/tags/') |
| 71 | + with: |
| 72 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + script: | |
| 74 | + try { |
| 75 | + await github.rest.repos.createRelease({ |
| 76 | + draft: false, |
| 77 | + generate_release_notes: true, |
| 78 | + name: process.env.RELEASE_TAG, |
| 79 | + owner: context.repo.owner, |
| 80 | + prerelease: false, |
| 81 | + repo: context.repo.repo, |
| 82 | + tag_name: process.env.RELEASE_TAG, |
| 83 | + }); |
| 84 | + } catch (error) { |
| 85 | + core.setFailed(error.message); |
| 86 | + } |
0 commit comments