Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use docker token #902

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ jobs:
# Export environment variables for all stages.
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_DEPLOY_IMAGES: false
# Pushing READMEs to Dockerhub currently only works with username/password
# and not with personal access tokens (Step: Update DockerHub description)
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
DOCKER_REPO: shfmt
# We use all platforms for which FROM images in our Dockerfile are
# available.
Expand All @@ -76,7 +74,7 @@ jobs:
# Get "https://proxy.golang.org/...": local error: tls: unexpected message
# Get "https://proxy.golang.org/...": x509: certificate signed by unknown authority
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0 # also fetch tags for 'git describe'
# Enable docker daemon experimental support (for 'pull --platform').
Expand All @@ -89,8 +87,8 @@ jobs:
echo '{ "experimental": true }' | sudo tee "$config"
fi
sudo systemctl restart docker
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
- name: Set up env vars
Expand All @@ -113,15 +111,15 @@ jobs:
echo "DOCKER_BASE=test/${{ env.DOCKER_REPO }}" >> $GITHUB_ENV
echo "DOCKER_BUILD_PLATFORMS=${DOCKER_PLATFORMS// /,}" >> $GITHUB_ENV
- name: Build and push to local registry
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
file: ./cmd/shfmt/Dockerfile
platforms: ${{ env.DOCKER_BUILD_PLATFORMS }}
push: true
tags: localhost:5000/${{ env.DOCKER_BASE }}:${{ env.TAG }}
- name: Build and push to local registry (alpine)
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
file: ./cmd/shfmt/Dockerfile
Expand Down Expand Up @@ -164,18 +162,18 @@ jobs:
run: |
missing=()
[[ -n "${{ secrets.DOCKER_USER }}" ]] || missing+=(DOCKER_USER)
[[ -n "${{ secrets.DOCKER_PASSWORD }}" ]] || missing+=(DOCKER_PASSWORD)
[[ -n "${{ secrets.DOCKER_TOKEN }}" ]] || missing+=(DOCKER_TOKEN)
for i in "${missing[@]}"; do
echo "Missing github secret: $i"
done
(( ${#missing[@]} == 0 )) || exit 1
echo "DOCKER_DEPLOY_IMAGES=true" >> $GITHUB_ENV
- name: Login to DockerHub
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Push images to DockerHub
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
run: |
Expand All @@ -200,9 +198,9 @@ jobs:
done
- name: Update DockerHub description
if: ${{ env.DOCKER_DEPLOY_IMAGES == 'true' }}
uses: peter-evans/dockerhub-description@v2
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
password: ${{ secrets.DOCKER_TOKEN }}
repository: ${{ secrets.DOCKER_USER }}/${{ env.DOCKER_REPO }}
readme-filepath: README.md